Issue with getRequestBody() in Attachment api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 04:03 AM
Attachment api is working fine and returning 201 status code but getRequestBody() always returns null what might be the issue with this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 05:38 AM
How are you calling getRequestBody()?
Here's the developer doco on how to use it in a REST message - https://developer.servicenow.com/dev.do#!/reference/api/yokohama/server/sn_ws-namespace/c_RESTMessag...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 05:47 AM
@Brad Warman Please find the script I am using
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setHttpMethod("post");
restMessage.setEndpoint("https://mytestdev.service-now.com/api/now/attachment/file");
restMessage.setBasicAuth('SN_INT_USER_IDM_User', 'CRbr#9extusrpr');
restMessage.setQueryParameter("table_name", "incident")
restMessage.setQueryParameter('file_name', 'ODOO and ServiceNow integration (AutoRecovered).docx');
restMessage.setQueryParameter('table_sys_id', '8f9a39a783e66610da0653a8beaad325')
restMessage.setRequestHeader("Content-Type", "application/json");
restMessage.setRequestHeader("Accept", "application/json");
restMessage.setRequestBodyFromAttachment("e4fd39afc366221001a098ec0501315e");
var response = restMessage.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var requestBody = restMessage ? restMessage.getRequestBody() : null;
gs.print("status" + " " + httpStatus);
gs.log("requestbody" + " " + requestBody);
gs.print("response body" + " " + responseBody);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 06:26 AM
What is the content of the attachment? You may need to update your content-type header to match the content type of the attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 06:40 AM
is the file getting sent over and attached to that record you mentioned?
If yes then it's strange.
Seems it's OOTB platform behavior.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader