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, UserID$header : $session.UserNo
You can pass second level
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.
Set the user token in customSessionInfo.
...
Code Block language java SessionManager.getInstance().setCustomSessionInfo(request,"token",UserToken);
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.
...
The data entered by end-users from client side can be captured and stored as extraParams and be sent as header params. 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.
Code Block | ||
---|---|---|
| ||
CWEH.registerHandler('TEST_APP', CWEC.EXTRA_PARAMS_HDLR, function(scope) { scope['loan_type'] = 'HOME_LOAN'; }); |
...