Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to pass the POST method response to the GET method header

Community Alums
Not applicable

Hi Experts,

I have requirement where I need to pass the POST method response to HTTP header value in GET method,
Below is the First Screenshot of POST method response, where the highlighted token which I need to pass into the GET method header value in 2nd screenshot.
Each time token value in the response will changes, so how can I fetch that value and pass it to the GET method header.
The Authentication type is : No authentication 

 

CHAITHANYA13_0-1669721926379.png

CHAITHANYA13_2-1669722061254.png

 


Thanks in advance,
Chaithanya

1 ACCEPTED SOLUTION

Swapna Abburi
Mega Sage
Mega Sage

@Community Alums 

You may use a script include to call first API and parse the token from its Response.

then call second api by setting header as below.

var token = from First API

var r = new sn_ws.RESTMessageV2('REST Message', 'HTTP Method');

r.setRequestHeader('X-Tableu-Auth', token);

 

You can set header for 2nd API as below

Key: X-Tableu'-Auth

value: ${token}

 

View solution in original post

4 REPLIES 4

Swapna Abburi
Mega Sage
Mega Sage

@Community Alums 

You may use a script include to call first API and parse the token from its Response.

then call second api by setting header as below.

var token = from First API

var r = new sn_ws.RESTMessageV2('REST Message', 'HTTP Method');

r.setRequestHeader('X-Tableu-Auth', token);

 

You can set header for 2nd API as below

Key: X-Tableu'-Auth

value: ${token}

 

Community Alums
Not applicable

Hi @Swapna Abburi 

Thank you for the reply.
Can you please provide the script include and steps to proceed.

Thanks,

Community Alums
Not applicable

Hi @Swapna Abburi 
The response from the POST method is in XML format, from that how can I fetch the required value?

Thanks,
Chaithanya

@Community Alums 

Please go thru the below article if it helps:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0957116