REST POST NOT WORKING
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-07-2018 12:12 AM
Hi All
I have created a REST POST API and i am triggering it from a business rule. Following the code of the rest call with in business rule. I have set it to accept form urlencoded value. the Cloud API to which this request is posted is configured to accept this format. Format of the Cloud API is - @Consumes(MediaType.APPLICATION_FORM_URLENCODED). It is written in JAVA. The problem i am facing is that everytime i run this code i get the error -
{X-Backside-Transport=FAIL FAIL, Connection=Keep-Alive, Transfer-Encoding=chunked, Content-Language=en-US, Date=Mon, 07 May 2018 05:50:19 GMT, X-Powered-By=Servlet/3.1, X-Global-Transaction-ID=2818294945}
**Payload logging not supported for unknown content-type.** Error 404
I tried testing Cloud API using postman and it works perfectly fine. The encoding I am using in postman is x-www-form-URLencoded. I am not able to understand why this format would work in postmam but not through servicenow
REST POST API triggered through business rule
Thanks a lot for your help
try {
var r = new sn_ws.RESTMessageV2('XXXX', 'XXXXXXX ');
r.setRequestHeader("cache-control", "no-cache");
r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
r.setStringParameterNoEscape('description', 'this is good');
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthentication(authentication type, profile name);
//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');
//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log(responseBody);
}
catch(ex) {
var message = ex.getMessage();
}}
)
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-07-2018 12:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-12-2018 05:17 PM
I had already done that, and still it was not helping.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-12-2018 08:53 PM
Maybe some more verbose logging would help. Have you tried turning on the rest debugging property and then looking at the node logs for the time span?
glide.rest.debug
View the logs here "System Logs > Node Log File Browser"
Set the timespan narrowly around the expected time
This might give you some more information to debug your issue.
Also have you opened a HI ticket on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-15-2018 03:35 PM
After much research i found out - MediaType.APPLICATION_FORM_URLENCODED is not supported in ServiceNow. I had to convert the media type to JSON and then change Java code to ensure that this works.
Turning on HTTP logs also helped me troubeshoot this.
Thanks to everyone who helped me here.