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.

REST OUTBOUND Integration

Naveen87
Tera Guru

Hello Developers,

 

I'm trying to create a REST OUTBOUND Integration.

I'm able to pass static & dynamic values but not both at the same time.

 

I want to send Description as 'static' & rest values as dynamic.

 

I have tried adding static description under HTTP Query Parameters & BR, Also tried by keeping them at 1 place either HTTP Query Parameters or BR. But no luck.

 

{

"description' : 'Naveen is learning Outbound Integration'

}

Please suggest.

 

var request = new sn_ws.RESTMessageV2('Naveen - Learning','Create Incident'); // REST Message & HTTP Method
request.setStringParameterNoEscape('u_caller_id',current.caller_id); // 'REST defined variable', 'source varaible'
request.setStringParameterNoEscape('u_short_description',current.short_description);
request.setStringParameterNoEscape('u_priority',current.priority);
request.setStringParameterNoEscape('description','Naveen is learning Outbound Integartion');

var response = request.execute();
var responseBody = response.getBody();
var statusCode = response.getStatusCode();
var responseError = response.getErrorCode();

gs.info("responseBody " + responseBody );

 

Naveen87_0-1709786192000.png

 

1 ACCEPTED SOLUTION

Kiranmai_KVL
Kilo Sage

Hi Naveen,

 

Can you check the integration user roles in the target instance? User must have 'sn_incident_write' role assigned as there is an OOB ACL on description field which allows only user's with the role to write to this field. If the role is missing, please add & give it a try. Let me know if it worked.

Kiranmai_KVL_0-1710024236808.png

 

Best Regards,

KK

 

View solution in original post

13 REPLIES 13

Amit Pandey
Kilo Sage

Hi @Naveen87 

 

Please use the following code and help me with the response body and errors so that I can assist you-

var request = new sn_ws.RESTMessageV2('Naveen - Learning', 'Create Incident');
request.setStringParameterNoEscape('u_caller_id', current.caller_id);
request.setStringParameterNoEscape('u_short_description', current.short_description);
request.setStringParameterNoEscape('u_priority', current.priority);
request.setStringParameterNoEscape('description', 'Naveen is learning Outbound Integration');

var response = request.execute();
var responseBody = response.getBody();
var statusCode = response.getStatusCode();
var responseError = response.getErrorCode();

if (statusCode === 200) {
    gs.info("Incident created successfully. Response body: " + responseBody);
} else {
    gs.error("Failed to create incident. Status code: " + statusCode + ", Error message: " + responseError);
    gs.error("Response body: " + responseBody);
}

@Amit Pandey ,

Incident was getting created earlier & it's creating now also. That's not an issue.

Issue is, Incident on target instance is not accepting the static Description values sent from Source.

 

I have kept the description empty on Source, So it could fetch from BR but that's not happening.

Naveen87_0-1709787118053.png

 

Naveen87_1-1709787178641.png

 

request.setStringParameterNoEscape('description', 'Naveen is learning Outbound Integration');

 

Hi @Naveen87 

Is your variable name correct, I see you have used "u_" for all the fields, except description.

Can you check if it is the correct variable name that you are passing.

Best Regards
Aman Kumar

@Aman Kumar S ,

I have used 'u' because these are variables & I have declared them which are called in BR.

description is not dynamic. Hence I'm calling the OOB field value with static string.

 
//request.setStringParameterNoEscape('description', 'Naveen is learning Outbound Integration');
 
But it's not accepting it. 
Not even dynamically now. IDK what's wrong.

Naveen87_0-1709788148461.png