Forum Discussion

Harsha3's avatar
Harsha3
New Contributor III
4 years ago

Reading attachment from service now

Hello,

I am trying to access the attachment and the data present in the attachment file (.csv). I used the rest snap to access the service now API endpoint. I was able to navigate to all the fields except the attachment.

Thanks,
Harshavardhana

5 Replies

  • Hi @Harsha3,

    If you want to access the binary file, there is a specific endpoint to do that:

    https://instance.servicenow.com/api/now/attachment/{sys_id}/file
    

    For more informations and guidelines head over to:
    Attachment API | ServiceNow

    Once you got the response you need to map it and change the output view on the Mapper Snap to binary, the mapping is shown below:

    And then you can use the CSV Parser Snap to parse the content.

    Let me know if this helps you,

    BR Aleksandar.

    • Harsha3's avatar
      Harsha3
      New Contributor III

      @AleksandarAngelevski

      Thanks for the reply, however, there is a 502 error when I am trying to invoke a REST API call. I got the sysid of the task but unfortunately, I could not proceed further.

      Thanks,
      Harshavardhana

      • Karuna_M's avatar
        Karuna_M
        New Contributor

        Hello Harsha,

        In the Rest Get Snap use the Response Entity Type as Binary and that should let you download the file.

        Thanks

  • Harsha3's avatar
    Harsha3
    New Contributor III

    Thanks @Karuna_M I was able to get the attachment response, can you please guide me on how to get the actual contents in the file.?This is the mapper response that I obtained after the REST GET response when invoking the attachment API of the service NOW.

    Thanks,
    Harshavardhana

    • Karuna_M's avatar
      Karuna_M
      New Contributor

      Hello Harsha,

      You can use the mapper snap to map the content, followed by Document to Binary and write it to a file.

      Thank You.