Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Attachment API - Attach a file by URL

Andr_1
Tera Contributor

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.

Andr_1_0-1693386761781.png

 
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

 

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

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

View solution in original post

5 REPLIES 5

Hello @Mohith Devatte 

I can confirm this will work as long as you have the file full URL 🙂
Thank you for your sharing