Has anyone used the REST "DELETE' method for outbound REST Messaging?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2019 06:46 AM
The field 'Content' was not visible on the form but I updated the UI Policy to show the content so i can use the JSON body. However, when I tried to test my DELETE method and hardcoding the values on my JSON body I get an error:
{"errors":{"":["A non-empty request body is required."]},"title":"One or more validation errors occurred.","status":400,"traceId":"|f7ba0e33b142d84a91d2e7f57a7cafb5.40b1f8fb_"}.
If I run my DELETE in Postman it works.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 07:29 AM
Hi A.R.G.
Here is my script. I receive an error message
var r = new sn_ws.RESTMessageV2('Polaris', 'retrieveOauthToken');
var response = r.execute();
var responseBody = response.getBody();
var parseBody = JSON.parse(responseBody)
var httpStatus = response.getStatusCode();
var token = parseBody.access_token;
gs.info("AccessToken:" + token);
var url = "https://mycompany.net/api/support/user/adjuster/";
var adjusterId = "318017";
var endPnt = url + adjusterId;
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setHttpMethod("delete");
restMessage.setEndpoint(endPnt);
restMessage.setMIDServer("MID_SERVER_NAME");
restMessage.setRequestHeader("Authorization", "Bearer " + token);
restMessage.setRequestHeader("Content-Type", "application/json");
restMessage.setRequestBody('{"adjusterId":"318017","bugTicket":"INC999999","updateByUserName":"ricky_manuel@mycompany.net"}');
// Execute REST API Call
var response1 = restMessage.execute();
response1.waitForResponse(60);
var resBody = response1.getBody();
var parseBody1 = JSON.stringify(resBody);
var httpStatus1 = response1.getStatusCode();
var str_code = '';
if (httpStatus1 > '199' && httpStatus1 < '301'){
str_code = 'Complete - '+ httpStatus1 + '\n'+'\n';
str_code = str_code + ' ' + parseBody1 + '\n';
} else {
str_code = 'Complete but Not Successful - '+ httpStatus1 + '\n'+'\n';
str_code = str_code + ' ' + parseBody1 + '\n';
// str_code = str_code + 'Bug Ticket: ' + bugTicket;
}
gs.print(str_code);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 09:59 PM
Hi Ricky,
you are setting the mid server name properly; give exact name of the mid server there
also what error message you are getting? can you share it?
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2019 06:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2019 11:05 PM
Hi Ricky,
Did you check with the 3rd party Team what does the error mean? any value not sent from your side.
error 400 means bad request so something is not sent properly in your request
Did you get sample request and response body from them so that you can compare
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2019 11:45 PM
Hi Ricky,
Any update on this?
Can you mark my answer as ✅ correct, 👍 helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader