Post

2 followers Follow
0
Avatar

Download document with REST API

I have been tasked with creating a routine to download specific documents given the External ID of said documents using the API.
I was able to bring back the Name and Url attributes with this call

https://api2.clarizen.com/v2.0/services/data/objects/Document/5b1fjvhkijktohha4mgq27p8w27982?fields=Name,Url

The Url attribute coming back is 473\1381473\5937\a8c0f10d-efeb-4cc9-9b6e-7bfc1f850413 which is not a usable link to download.

When I go into Clarizen in a browser and find the file download link it is

https://app2.clarizen.com/Clarizen/Pages/FileHandling/OpenDocument.aspx?po=34.448072641.1381473 which is usable to actually transfer the file.

I do not see anything in the Url attribute related to the actual download link.

What would be the best way to acquire this download link through the API?

Thanks,

Dan

Daniel Kelly Answered

Official comment

Avatar

Hi Daniel,

If you have the document id you can use the "download" action (https://api2.clarizen.com/V2.0/services/files/Download) to retrieve the document url.

For example:

https://api2.clarizen.com/V2.0/services/files/download?documentId=/Document/54tq2hswnfn5inzlsuxz7dtcy0

(Where "/Document/54tq2hswnfn5inzlsuxz7dtcy0" is your document id)

Will give a response like this:

{
    "fileInformation": {
    "storage": "Server",
    "url": "https://api2.clarizen.com/V2.0/services/files/49.61.1-636409794542748896-FC614B691E56168840961/downloadFile",
    "fileName": "op.csv",
    "extendedInfo": "Document"
   }
}

 

Use the url value to download the document.

 I hope this helps,

Elad

Elad Franklin
Comment actions Permalink

Please sign in to leave a comment.

2 comments

0
Avatar

This is perfect.  Exactly what I needed.

Thank you, Elad

Daniel Kelly 0 votes
Comment actions Permalink