Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

ResponseBody blank

kchorny
Tera Guru

I am building an integration between instance1 and instance2. When instance2 posts to the web service on instance1, the incident gets created correctly but I get no response body so I'm unable to pull the remote number out and set it on the initiating incident.

find_real_file.png

When I use REST API Explorer on instance1 and post to the same web service, I get the appropriate response body.

Here is my code:

var request = new sn_ws.RESTMessageV2("ABC Outbound Incident","create_incident");
request.setStringParameterNoEscape("summary",current.short_description);
request.setStringParameterNoEscape("description",jsonEncode(description + ''));
request.setStringParameterNoEscape("number",current.number);
request.setStringParameterNoEscape("company","XYZ");
request.setStringParameterNoEscape("caller","XYZHelp Desk");
request.setStringParameterNoEscape("reported_by","XYZ Help Desk");
request.setStringParameterNoEscape("urgency",urgency);
request.setStringParameterNoEscape("impact",impact);
request.setStringParameterNoEscape("group","Service Desk");
request.setStringParameterNoEscape("sysID",current.sys_id);
request.setStringParameterNoEscape("state","Queued");
request.setStringParameterNoEscape("substate","New");
request.setStringParameterNoEscape("comments",jsonEncode(comments + ''));
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.addInfoMessage('httpStatus: ' + httpStatus);
gs.addInfoMessage('responseBody: ' + responseBody);

 

What is going on?

1 ACCEPTED SOLUTION

kchorny
Tera Guru

For anyone who stumbles on this post in the future, I fixed this by giving the user on instance1, whose credentials instance 2 was using to send data to instance1, the import_transformer role to get a response back.

View solution in original post

9 REPLIES 9

Rahul Kathuria
Tera Expert

Hi,

Can you try this line of code to execute:

 


var response = request.executeAsync();
// Get The Response Body
var responseBody = response.getBody();

That gives me this:

find_real_file.png

eduque
Giga Expert

REST API explorer might have interpreters built in for responses.

I'd check what you're getting as a response:

gs.addInfoMessage('responseBody: ' + typeof responseBody);

If it's not a string, you might need to do something with responseBody before it can display properly

kchorny
Tera Guru

For anyone who stumbles on this post in the future, I fixed this by giving the user on instance1, whose credentials instance 2 was using to send data to instance1, the import_transformer role to get a response back.

It does not help in this scenario getting reponse body from other instance as **Payload logging not supported for unknown content-type.**