Transferring attachments through REST API's using nodejs
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 01:19 AM
Hi Team,
I need help transferring attachments from ticket to other ticket between different tables in ServiceNow. I tried with all the possibilities with my knowledge.
This is the code to get attachment content
let file = {
method: "GET",
url: https://${service-now instance}/api/now/attachment/${sys_id of attachment}/file,
headers: {
authorization: this.getBasicAuthorizationToken(
itsmData.principal,
itsmData.secret
),
responseType: "arraybuffer",
},
};
let image = await axios(file);
let base64data = await Buffer.from(image.data).toString("base64");
let data = await Buffer.from(base64data, "base64");
Sending data as attachment content into POST attachment call for uploading file. File is getting uploaded, but the data is corrupted. If I have done this through postman and followed same process after saving response to local it's working good.
Please help me to fix this, if it's possible. I am using node v14.15.1 to develop this.
Please help me to fix this, if it's possible. I am using node v14.15.1 to develop this.
0 REPLIES 0