API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
Expand all | Collapse all

Reading header variable value in gatewayscript

  • 1.  Reading header variable value in gatewayscript

    Posted Sat March 06, 2021 10:41 AM

    Can someone look into this issue.

    From xslt after our logic execution we are setting token value in one of the new header by using below.

    <dp:set-request-header name="'token'" value="$TokenValue"/>

    Immediate policy is gatewayscript. How we can read above set variable value in gatewayscript.

    We are reading as per below. But everytime it's showing undefined for all the below statements.

    Is there anyother alternative option because I want to read variable value in Gatewayscript which is set in xslt.

    var content= apim.getvariable('token');

    var content = apim.getvariable('request.headers.token');

    var content = apim.getvariable('message.headers.token');



    #APIConnect
    #Support
    #SupportMigration


  • 2.  RE: Reading header variable value in gatewayscript

    Posted Sat March 06, 2021 03:33 PM

    I need to see more code to figure out what you are trying to accomplish

    This is the primary IBM manual for their XSLT offerings

    https://www.ibm.com/support/knowledgecenter/en/SS9H2Y_7.7.0/com.ibm.dp.doc/welcome.html



    #APIConnect
    #Support
    #SupportMigration


  • 3.  RE: Reading header variable value in gatewayscript

    Posted Sat March 06, 2021 04:02 PM

    We have one xslt file where it will call back end url by using dp:url-open and get the token for my input json object. This token I need to set in header as token and after that I need to invoke another service call with some other body message to get the actual service response.

    Here in xslt after receving the token I am trying to set in header: <dp:set-request-header name="'token'" value="$TokenValue"/>. This is the header expected by backend system while invoking 2nd endpoint. After setting in xslt also it is not setting in header before invoke call of my 2nd endpoint. I thought of reading variable in gatewayscript and set there to message.headers.token and invoke the 2ndpoint with someother body input . If I hardcode this value with header name as token in gatewayscript and after that invoking 2nd endpoint is giving response.

    apim.setvariable('message.headers.token','123');

    But I am not able to read this variable in gateway script which already set in previous xslt file as as request header.

    Kindly let me know still if you are looking for my code snippet of xslt.



    #APIConnect
    #Support
    #SupportMigration