- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 03:48 AM
Hello,
I am testing the Attachment API (Upload an attachment from binary request (POST) with the "Rest API Explorer" module to see if it works correctly for my needs.
I uploaded a file from my computer (local) and when I try to send, it works well.
Now my question is How can I attach a file from a URL instead of uploading it locally? I have a URL with a PDF file and I want to attach this file to the HR Case form.
Thank you
Solved! Go to Solution.
- Labels:
-
Human Resources Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:15 AM - edited 08-30-2023 04:16 AM
Hello @Andr_1 ,
I think you might have to do it via script using RESTMESSAGEV2 API like below
var attachmentMessage = new sn_ws.RESTMessageV2();
try {
attachmentMessage.setHttpMethod("get");
attachmentMessage.setEndpoint(targetInstanceURL);
attachmentMessage.saveResponseBodyAsAttachment("incident", {record sys_id}, {filename});
var response = attachmentMessage.execute();
var httpStatus = response.getStatusCode();
} catch(ex) {
gs.info("ERROR (sendAttachments): " + ex);
}
}
Note :This is untested , but try giving it a shot .If it works let me know
Replace targetedInstanceURL with your Teams link
If this helps
Mark the answer correct
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:02 AM
it depends on which application is consuming the endpoint
What's your business use-case here?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:08 AM
thank you for your feedback.
I think that I did not get your question.
I am building a integration with Microsoft Team, and I want to attach a file from Teams to the HR Case form, but the file is in URL format.
I just want to know how can I import the URL file in the Attachment API instead upload directly the file from my computer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:14 AM
with just file url you cannot attach file.
you need to fetch the file using API and then attach it to record
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:15 AM - edited 08-30-2023 04:16 AM
Hello @Andr_1 ,
I think you might have to do it via script using RESTMESSAGEV2 API like below
var attachmentMessage = new sn_ws.RESTMessageV2();
try {
attachmentMessage.setHttpMethod("get");
attachmentMessage.setEndpoint(targetInstanceURL);
attachmentMessage.saveResponseBodyAsAttachment("incident", {record sys_id}, {filename});
var response = attachmentMessage.execute();
var httpStatus = response.getStatusCode();
} catch(ex) {
gs.info("ERROR (sendAttachments): " + ex);
}
}
Note :This is untested , but try giving it a shot .If it works let me know
Replace targetedInstanceURL with your Teams link
If this helps
Mark the answer correct
Thanks