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.

Request Body is going empty when sending a REST API request outbound

maneesh3
Tera Contributor

Hi Team,

 

I am working on a REST API integration with a third party application and while sending data from ServiceNow, I am unable to send the parameters in Request Body. Client is asking for to send data through Request Body: Following I have approached:

 

maneesh3_0-1761128699522.png

 

 

Below I have given in PUT method:

maneesh3_1-1761128741588.pngmaneesh3_2-1761128795344.png

 

Although Request body is null.

 

Please suggest where I am doing wrong.

 

Thank you!

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@maneesh3 

you didn't share the script which you are using to call and are you substituting the variables?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@maneesh3 

any update to above comment?

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

Hi Ankur,

 

Can you please help on above, I have attached script.

 

Thanks,

 

Hi Ankur,

 

Thanks for your reply, yes I am using substitutes and below script BR to call:

 

(function executeRule(current, previous /*null when async*/ ) {
var comment_text = current.comments.getJournalEntry(1);


comment_text = comment_text.replace(/[\r\n]+/g," ");


   
    var req  = new sn_ws.RESTMessageV2('vCx360', 'Default PUT');
    req.setRequestHeader("Content-Type", "application/json");
   
        //req.setRequestBody(JSON.stringify(payload));
    req.setStringParameterNoEscape('short_description', current.short_description);
    req.setStringParameterNoEscape('description', current.description);
    req.setStringParameterNoEscape('correlation_id', current.correlation_id);
   
  // req.setStringParameterNoEscape('comment', current.comments.getJournalEntry(1));
     req.setStringParameterNoEscape('comment', comment_text);  
    req.setStringParameterNoEscape('number', current.number);
   

   
    var response = req.execute();
    var responseBody = response.getBody();
    var httpStatus = response.getStatusCode();





})(current, previous);









Thank you!