How to send pdf files as a binary data in attachment api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 11:14 AM
Hi ,
I have create attachment API but PDF file is getting corrupted when send through API.
1. How can I send pdf file in binary format ?
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 11:16 AM
My response in a previous question (post: Re: Business rule to send attachment to 3rd Party Tool via REST )
The easiest way is to use the RestMessageV2 in your script and use setRequestBodyFromAttachment(). It will put the binary of the attachment into your request body, no converting needed.
Docs: RESTMessageV2 - setRequestBodyFromAttachment(String attachmentSysId)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 11:48 AM
Hi Jarod,
Thanks so much for your reply.
Can you please let me know how can send attachment in raw data.
for eg I am using below to send create incident :
[
{
"req_short_description":"test5",
"req_user_name":"fdudon",
"attachment" : [
{
"req_content_type":"plain/text",
"req_binary_input":"YWJjZA==",
"req_file_name":"tp12.txt"
},
{
"req_content_type":"plain/text",
"req_binary_input":"bmxqZGc=",
"req_file_name":"tp21.txt"
}
]
}
]
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 11:16 AM
Please refer below post which has solution to your question.
Sending a pdf to the Rest API with javascript
Regards,
Sachin