How to call a DELETE method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 06:34 AM
We have a delete method API which has parameters from variable.How to trigger it form script incude and get the status from workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 11:50 PM
ID and number is variable in the catalog form we have created. The delete operation happens in the system where we are calling the API.
When are you calling the rest api given in the try-catch block?........... In the workflow defined for the item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 11:58 PM
Hi,
so you are trying to delete catalog variable?
the table which stores that is "item_option_new"
Can you share more details on this what exactly is required?
Also DELETE endpoint requires table name and record sys_id to delete
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
Regards
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
06-18-2020 11:39 PM
Hi,
Check this sample code.
try {
var userID = "testUserID";
var requestBody = {
"userId": 0,
"bugTicket": "string",
"updateByUserName": "string"
};
var r = new sn_ws.RESTMessageV2();
r.setEndpoint('https://userapi-company_name.net/api/support/user/adjuster/'+userID);
r.setHttpMethod('DELETE');
r.setMIDServer('MY_MID_SERVER');
r.setRequestBody(requestBody);//Strigfy it if it doesnt work
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log("Recieved response from 3rd party "+httpStatus+" | "+responseBody);
}
catch(ex) {
var message = ex.message;
}
If my answer helped you in any way, mark answer as helpful and correct.
Thanks and regards,
Megha.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 11:51 PM
We dont have a request body, the URL has the parameters