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.

Outbound rest integration

shaik siddik
Tera Contributor

Hi,

I have tried simple rest outbound integration. If we create a incident record in one instance then another record should be created in demo table of another instance. I have written business rule to trigger api. For static values it is working fine. if i want dynamic values of short description and description field it is not working can you guide me to achieve this.

 

In the content field if i assign static values it is working fine. if i try to get dynamic values it is not working.

 

BUSINESS RULE:

 

var request = new sn_ws.RESTMessageV2('incident integration','insert record');
    request.setStringParameter("field1",current.short_description);
    request.setStringParameter("field_2",current.description);

    request.execute();
    gs.addInfoMessage('executed');

    var response = request.execute();
    var requestbody = request.getRequestBody();
    var responsebody = response.getBody();
    var httpstatus = request.getStatusCode();
    gs.log("request body is "+ requestbody);
    gs.log("response body is "+ responsebody);
    gs.log("http status is"+ httpstatus);
 
POST HTTP METHOD

integration 1.PNG

integration 2.PNG

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @shaik siddik 

 

there is a bug in your code when it comes to fill in the placeholders in your REST message body. The correct version is:

request.setStringParameter("short_description",current.short_description.toString());
request.setStringParameter("description",current.description.toString());

 

Maik

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi @shaik siddik 

 

there is a bug in your code when it comes to fill in the placeholders in your REST message body. The correct version is:

request.setStringParameter("short_description",current.short_description.toString());
request.setStringParameter("description",current.description.toString());

 

Maik

If i try this 2 records are created at same time. can you guide where i went wrong. i have user before insert business rule