Passing Data as Header Parameter in Request

Canvas now enables you to configure the parameters that can be passed in the header of a request. This helps in sending data to a web service that expects a key or information in the header to return a response for a request. In some instances, you may require to pass header parameters to GET and POST requests and for operations such as publish, update, fetch or to pass through a filtered layer to connect a web service.

In the Request JSON Configuration field, provide the inputs as follows for the header of the request.

Example,             param$header  : $session.param

In the above example, "param" can be any parameter that you want to pass in the header. "$header" is the header object to pass the data in it. "$session" is the session object where you are accessing the data value from. ".param" is the parameter available in the session that you want to fetch and set in the header.

For example, if you want to pass User ID of a user in the header, you can fetch the User ID from any of the predefined objects such as request, session, extraParam etc. that contain the value and pass it in the header in the following format. Refer Canvas Reserved Keywords and Predefined Objects for more details.

Example,             UserID$header : $session.UserNo

If you want to fetch the user token and pass it with the request in the header for authentication purpose, you can pass data to the header using customSessionInfo by the following steps below.

  1. Set the user token in customSessionInfo.

    SessionManager.getInstance().setCustomSessionInfo(request,"token",UserToken);
  2. Get the UserToken from customSessionInfo and set it in the header in Canvas Studio.

    AuthToken$header : $customSessionInfo.UserToken


The following are canvas provided parameters for the predefined objects; session and user. The implementation teams can use these parameters to pass the data in the header.

sessionuser

sessionId

owningGCIF

deviceType

currentGCIF

channelId

userNumber

hybridAppFlag

loginId

simulatedFlag

userType

simulatingUserLoginId

firstName

requestingClientIP

middleName

browserName

lastName

osName

mobileNumber

sessMode

emailId

usrAgent

customerSegmentCode

sessInfoData

currentRoleId

sessionCache



corpRoles

corpRoleDescriptions

authenticationType

The data entered by end-users from client side can be captured and stored as extraParams and be sent as a header parameter. You can fetch user details from client side and set them in extraparams. 

loanType$header : $extraParams.loanType

The following snippet is a sample code to achieve that. 

CWEH.registerHandler('TEST_APP', CWEC.EXTRA_PARAMS_HDLR, function(scope) {

scope['loan_type'] = 'HOME_LOAN';

});

Copyright © Intellect Design Arena Limited.

All rights reserved. These materials are confidential and proprietary to Intellect Design Arena Limited and no part of these materials should be reproduced, published in any form by any means, electronic or mechanical including photocopy or any information storage or retrieval system nor should the materials be disclosed to third parties without the express written authorization of Intellect Design Arena Limited.