Expand my Community achievements bar.

SOLVED

Download document using the API

Avatar

Level 10

Hello,

 

I would like to download the binary of a document via the API to get a blob object. 

Is this somehow possible? I cannot find the corresponding information using the API-explorer.

I know, that I can retrieve the field downloadURL, but using this requires to be logged in to Workfront.

 

Thanks in advance.

 

Regards

Lars

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

That's what you have to do. You have to get the download url, and then download it with that url, and both of those require an API key or a session ID.

View solution in original post

15 Replies

Avatar

Correct answer by
Community Advisor

That's what you have to do. You have to get the download url, and then download it with that url, and both of those require an API key or a session ID.

Avatar

Level 3

How can I get the file extension in the endpoint -  /attask/api/v17.0/document/search?projectID=xxxxxxxxx&fields=folders,downloadURL . I tried adding fileType, but I'm getting below message.

 

"field 'fileType' is not available"
Could you please help?

Avatar

Community Advisor

The file Type parameter is on the version object, so if you include currentVersion:ext, that should give it to you.

Avatar

Level 3

Thanks a ton!

Avatar

Level 1

Hey Chris,

This information has be quite useful, however curious how to navigate the Download URL call returning the HTML webpage vs. downloading the binary. The API Key authenticates, but does returns the HTML page. Any thoughts?

Avatar

Community Advisor

So since this thread still gets random replies and likes, I'll go ahead and post an update here. You can now generate a pre-signed URL for a file and just download files with that pre-signed URL instead of needing a session ID. The previously mentioned method still works, there's just now an alternative.

Avatar

Level 1

Hi Chris, 
Is there any documentation for this?
I have a similar scenario where I need to download assets and move them to azure blob storage. 

I have attempted to use adobe IMS, but it seems the developer user isnt granted access to file information in workfront. 
We are currently using a static refresh token. We have a vmss, and rotating the refresh token is too complex for this scenario. 
There is also the option of using the workfront OAuth integration but that leads us to having to manage certs, which we are trying to eliminate. 

Avatar

Community Advisor

You have to be able to make an authenticated call to the document end-point, so provided you can do that it's the "getTemporaryCloudURL" command listed under documents. You provide the document version ID you want a URL for, as well as a TTL for it, and then you get a pre-signed S3 download link.

Avatar

Level 2

I am also having a problem downloading a document. I am providing an apiKey (I've tried in both $body and $header) in a CURL command through Powershell.

The $url variable contains something like this:
https://<mycompany>.my.workfront.com/internal/document/download?ID=abc123456def123456
$downloadResponse = Curl -Uri $url -Header $header -Body $body -OutFile $downloadPath

All I am getting back is a 4k file, starting with this:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 
<body onload="document.forms[0].submit()">
<noscript>
<p>
<strong>Note:</strong> Since your browser does not support JavaScript,
you must press the Continue button once to proceed.
</p>
</noscript>

 

Avatar

Level 1

Having the exact same error. If i open the provided URL in my browser it downloads just fine; but trying to do it programmatically produces an error.

 

Were you able to solve the issue?

Avatar

Level 1

The SessionID needs to be added either as a parameter in the download URL (&sessionID=) or the header (sessionID:''). SessionID can be retrieved from ..attask/api/v19.0/session

Avatar

Level 1

I'm having the same error any one help please!

Avatar

Level 1

Have you added the sessionID to you download request?

Avatar

Level 1

Hi @jshaw4 - were you able to get download working? I tried to generate the session based on the documentation `attask/api/v21.0/session` and that call failed with AuthenticationException.

 

Thanks,

 

Chinh

Avatar

Level 1

This is resolved. Our client had to regenerate a different API key for the user. Once that happened, the session endpoint worked. Added the sessionID (along the APIKey) to the downloadURL (which should be 

https://<your_domain>.my.workfront.com/{downloadURL}). That should work.