- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2017 06:05 PM
I get the above error when running the following code:
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('post');
r.setBasicAuth('<username>', '<password>');
r.setEndpoint('<instance>/api/now/attachment/file');
r.setRequestBodyFromAttachment('<attachment sys_id from local instance>');
var response = r.execute();
gs.info(response.getStatusCode());
gs.info(response.getBody());
Output:
Unexpected behavior from remote host: Unbuffered entity enclosing request can not be repeated.
Response:
Status Code: 0
Body:
I'm essentially trying to upload attachments from local records to another instance.
Any suggestions/corrections? I'm unable to understand the error and am fairly new to developing on ServiceNow
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 02:48 PM
Thanks aakashshah!
Your links were very useful and while they did not directly get me the answer I needed, I made a bunch of changes that got my code working. Some of the important ones that might have helped my cause are:
- Corrected http to https in my external host
- Used a REST Message call as opposed to directly passing api in
setEndpoint
- Using
new sn_ws.RESTMessageV2('<api_name>', 'POST')
instead ofnew sn_ws.RESTMessageV2('<app_name>.<api_name>', 'POST')
Hope this helps others in the future

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2017 09:16 PM
Hi AdityaDev,
Based on your requirement you can go through these links. I hope you find them helpful
RESTMessageV2 - setRequestBodyFromAttachment(String attachmentSysId)
How to retrieve an attachment from service now via SOAP Web Service
Copying attachment from one instance to another+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 02:48 PM
Thanks aakashshah!
Your links were very useful and while they did not directly get me the answer I needed, I made a bunch of changes that got my code working. Some of the important ones that might have helped my cause are:
- Corrected http to https in my external host
- Used a REST Message call as opposed to directly passing api in
setEndpoint
- Using
new sn_ws.RESTMessageV2('<api_name>', 'POST')
instead ofnew sn_ws.RESTMessageV2('<app_name>.<api_name>', 'POST')
Hope this helps others in the future