Fetch Response details and update worknote

Ujjwal1
Tera Contributor

hi 

I am using REST method to POST. this is triggered via script include.

in outbound Http log .

Ujjwal1_0-1746194379177.png

please suggest how to fetch this message in script include.

 

Thanks

Ujjwal

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Ujjwal1 

share the complete script here

you should be able to get the response body like this using the OOTB function of REST Message

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('EndPoint');
request.setHttpMethod('POST');

//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';

request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');
request.setRequestBody('{"u_catalog_item":"Blackberry",' +
                            '"u_variables":"original^299-999-9991|' +
                            'replacement^Yes"}');
var response = request.execute();
gs.log(response.getBody());

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ujjwal1
Tera Contributor

thanks @Ankur Bawiskar  for response.

 

with response.getBody()

i am getting below response(captured in gs.log)

Ujjwal1_0-1746450332091.png

 

but in outbound Http log below message is captured. how to get this in script include.

Ujjwal1_1-1746450422351.png

please suggest

 

Thanks

Ujjwal

 

 

@Ujjwal1 

it's giving error 500 means some internal server error and hence returning some HTML content

Did you check with 3rd party team regarding this?

what's your next requirement, you already got the response body printed in logs?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

issue is .. i need to update worknote with response message. but i am not getting reponsebody message in script include.