AnsweredAssumed Answered

Downloading incident attachments via the API

Question asked by Applications on May 31, 2018
Latest reply on Jun 4, 2018 by Devin Janus

When I retrieve an incident's details via the API, the response body contains attachments details, e.g:
$ curl --digest -u '[username]:[password]' -H 'Accept: application/vnd.samanage.v1.3+json' -X GET 'https://api.samanage.com/incidents/23977197.json?layout=long'
...
   "attachments":[  
      {  
         "id":18548779,
         "content_type":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
         "size":2332868,
         "filename":"Campaign GPS screenshots 20180411.docx",
         "url":"https://s3.amazonaws.com/Production_CustomerData/attachments/25bbb3bb8744a0b1f9b4/Campaign%20GPS%20screenshots%2020180411.docx?AWSAccessKeyId=AKIAJVLMJ2APFKWLI5KA\u0026Expires=1525393378\u0026Signature=81EFWt%2FzJvfzhaMNNOWiOFFbmnA%3D",
         "shared_attachment":false,
         "attachable_id":23977197,
         "attachable_type":"Incident",
         "attachment_type":"attachment",
         "thumb_url":"/attachments/25bbb3bb8744a0b1f9b4/campaign-gps-screenshots-20180411-docx.vnd?thumb=true",
         "secure_url":"/attachments/25bbb3bb8744a0b1f9b4/campaign-gps-screenshots-20180411-docx.vnd",
         "uuid":"25bbb3bb8744a0b1f9b4"
      }
   ],
...
However I don't seem to be able to download the file via the API using any of the URLs provided in the response. The secure_url redirects to the Amazon S3 url, following the redirect results in an Access Denied error:
$ curl -o attachment.docx "https://s3.amazonaws.com/Production_CustomerData/attachments/25bbb3bb8744a0b1f9b4/Campaign%20GPS%20screenshots%2020180411.docx?AWSAccessKeyId=AKIAJVLMJ2APFKWLI5KA\u0026Expires=1525898206\u0026Signature=X56xUhJon0TVD7Lrjx%2B9eFRy2oU%3D"
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>94E5D2E25B956375</RequestId>
<HostId>
faIeeIl3GREtitBAlMjOynUyicn13UzcK0+0nEtd6Qjsg9wIr2IX7tyHW6l6bdglPHKTSy5tb+c=
</HostId>
</Error>

 

The Amazon URL appears to be valid for about 10 minutes, and I sent the request within that time limit. Why am I getting an access denied error?

Outcomes