Api content management documents download a document

Hi Folks!

I'm working on a project that will need to download files from genesys cloud.

A third-party application needs to download files to use them on a page that the customer can download.

I saw that there is the API /api/v2/contentmanagement/documents/{documentId}/content
to this end.

My problem is when downloading the document using contentLocationUri I have the return:

<Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<X-Amz-Expires>20</X-Amz-Expires>
<Expires>2021-10-29T13:34:56Z</Expires>
<ServerTime>2021-10-29T14:04:51Z</ServerTime>
<RequestId>ECA0A6G0JRKBSXYN</RequestId>
<HostId>
mgie/0EuPBsDRz52KPq2mjkzUrDXWbYX7pJytQug+i36a41jzwiNcfj160Hc4vsYiVu0967qzuw=
</HostId>
</Error>

I'm calling passing disposition = attachment (already tried as inline)

Any tips or examples on how to get the files' download url via a third party application?

Thank you in advance for the forum help

Hello,

The URL you get in contentLocationUri has a limited lifetime (signed signature/token with limited duration for its validity).
The document/file is made available on AWS and I see that the url contains X-Amz-Expires=20. Which means that you likely have 20 seconds to start the download of the file.

After it expires, you can request /api/v2/contentmanagement/documents/{documentId}/content endpoint again, and it will give you a new url (new signature/token valid for next 20 seconds).

Regards,

1 Like

Hi @Jerome.Saint-Marc , thx a lot for your quick reply :mechanical_arm:

what's the difference between disposition types (attachment and inline) ?

To load the file on a html page should i use "inline"?

Greetings

From what I understand (I have just run the query with inline and attachment):
With inline, the request to the contentLocationUri returns HTML (document data embedded in html/body elements).
With attachment, it returns the document data.

"To load the file on a html page should i use "inline"?"
I would say both would work - it just depends what you do with the contentLocationUri you get in your web page/javascript.
If you want to display the document in a new tab, with no special/additional javascript code or html formatting, or in an iframe, you could indeed use inline and it will give you an HTML page you can display directly/as is.

Regards,

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.