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.

RITM Rest API Integration

reks
Kilo Contributor

Hi Guys,

I am doing RITM integration servicenow to servicenow using REST API.

I have created REST Outbound POST method.

content = {"number":"${number}","comments":"${comments}","request_item":"${request_item}"}

am setting the values for the above variables.

for the variable 'request_item' -   i want to create a custom payload, where i want to sent the list of all RITM's created for the request with variables for each RITM.

Sample payload.

"request_item": [

              { "number":"RITM1312312", "variables":[ { "name":"BMW", "value":"testing" },{ "name":"BMW1", "value":"testing" } ] },

              { "number":"RITM123123", "variables":[ { "name":"BMW", "value":"testing" },{ "name":"BMW1", "value":"testing" } ] }              

      ]

So that, at the other instance i can print the length of 'request_item' ,which gives me 2 and use for loop and set all variable names with corresponding values.

Please help me like how to set value to the variable (request_item) in the above format and how to fetch the values for the same variable in other system.

var r = new sn_ws.RESTMessageV2('RITMIntegration', 'POST');

r.setStringParameterNoEscape ('number', current.number);

r.setStringParameterNoEscape ('comments', current.comments);

Appreciate your inputs.

Thanks,

Rekha

5 REPLIES 5

What is the data in requestBody.data;?



You can try requestData.variables.length;   //assuming this is an array in json



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response