HTTP REST API Delete Method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 12:46 PM
Does Servicenow Support Request Body for Delete Method ? While Sending the Request to 3rd party with HTTP Delete function using Rest Message API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 01:02 PM - edited 05-15-2023 01:05 PM
Hello @yad_achyut,
ServiceNow Outbound REST messages do support the DELETE HTTP method. To set the method to DELETE in a script, do the following:
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('delete');
var body = "<Message body content>";
request.setRequestBody(body);
Full documentation on the RESTMessageV2 API can be found here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 06:46 AM
@Benjamin A But this is not working i am getting an error saying the {a non-empty request body is required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 11:07 AM
Could you please elaborate on exactly what you are trying to do? I was able to run the following as background script without any issues.
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('delete');
request.setEndpoint('https://webhook.site/1eb5c739-e641-43cb-986c-51bc50dc7c0d'); // Website to test webhooks
request.setRequestHeader('content-type', 'application/json');
var body = "{field: test}";
request.setRequestBody(body);
var response = request.execute();
gs.info(response.getStatusCode());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 08:14 AM
Hi Benjamin,
This also wont work as REST in snow doesn't allow body for DELETE Methods