How to send attachment from one servicenow to another servicenow using integration

manju12
Tera Expert

Hi,

 

Could any one help me how to send attachment from one instance to another instance using rest method (integration).

I got the error like  {"error":{"message":"Attachment is empty","detail":null},"status":"failure"}. 

2 REPLIES 2

Sai Shravan
Mega Sage

Hi @manju12 ,

 

To send an attachment from one instance to another instance using REST methods, you'll need to ensure that you're correctly handling the attachment data and formatting it in the request. The error you received, "Attachment is empty," suggests that the attachment data was not properly included in the request.

Here's a step-by-step guide on how to send an attachment using REST:

1. Prepare the attachment data: Ensure that you have the attachment file ready and accessible on the source instance. Make sure the file exists and can be read by your application.

2. Convert the attachment data into the appropriate format: Attachments are typically sent as binary data, so you'll need to convert the attachment file into a suitable format for transmission. Depending on the integration or API you're using, you may need to encode the file using Base64 or another encoding scheme.

3. Include the attachment data in the request: In the REST request, the attachment data is often included as part of the request payload or body. Verify that you've properly encoded the attachment data and included it in the request body.

4. Set the appropriate headers: Ensure that you set the appropriate headers in your request, including the content type for the attachment data. For example, if you're using Base64 encoding, you may need to set the Content-Type header to application/base64 or application/octet-stream.

5. Send the request to the destination instance: Make sure you're sending the request to the correct endpoint or URL of the destination instance. Double-check that the URL and any required authentication or authorization headers are properly configured.

6. Handle the response: Once the request is sent, you should receive a response from the destination instance. Check the response status code and response body for any error messages or additional details. The specific error message you encountered suggests that the attachment data was not included correctly or was empty.

By following these steps and ensuring that you handle the attachment data properly, you should be able to send attachments between instances using REST methods.

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you

Hi Shravan,

Thank you. Now it is working partially, attachment is passing to another instance but it's not open I think issue in Accept and Content-Type?  I have attached screenshot below 

manju5_0-1689070825311.png