Expand my Community achievements bar.

not able to get handle for doc uploading

Avatar

Level 1

AdminUs6_0-1739525613008.png

I'm trying to use python to upload a file to workfront, according to the userguide, I should get a 'handle' when I sent a post request to /attask/api/v15.0/upload, but I only got a response 401 "com.attask.common.AuthenticationException". I found "uploadedFile" is necessary for the request, I tried but still return 401. could anyone help to provide a python example of how to upload a file? MANY THANKS!!!!

 

Here is the code I used. 

dest = self.domain_url+'/attask/api/upload'

params['uploadedFile'] = filename

files = [('uploadedFile', open(filename,'rb'))]
response = requests.post(dest, data = params, files = files)

2 Replies

Avatar

Employee

Hello AdminUs6.  Thanks for posting the problem you're facing.

 

I could be wrong, but the error you are seeing (with a 401 and AuthenticationException) is likely not related to the parameters for `uploadedFile` and such, but more related to how you're authenticating your request.

 

Here is the documentation that describes your authentication options: https://experienceleague.adobe.com/en/docs/workfront/using/adobe-workfront-api/api-general-informati....

 

If the problems were specific to your upload parameters and such, then you would be getting a 403 error.  As it's a 401, I don't think it's specific to uploading files, as much as it is about how you're authenticating your request.

 

In order to better help you debug this problem, please provide details about how you are currently authenticating your request.  Please don't send anything confidential, as this is a public forum, but describe the headers and/or query parameters you are sending.

 

Also, in the response headers, there is a request ID.  Including that would be helpful for more debugging on our end.

 

If you want to open up a customer issue, you can also visit this page: https://experienceleague.adobe.com/en/docs/workfront/using/basics/tips-tricks-for-basics/contact-cus....

 

Thanks.

Avatar

Level 2

It looks like you're running into an authentication issue with the 401 error. That typically means the API isn’t recognizing your credentials. You’ll need to make sure you're sending the correct authentication headers (usually an API key or OAuth token) with your request.

Here’s a basic example with authentication headers:

python
Copy
Edit
import requests

url = "https://yourdomain.attask-api.com/attask/api/v15.0/upload"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
params = {
'uploadedFile': 'filename'
}

files = {'uploadedFile': open('filename', 'rb')}
response = requests.post(url, headers=headers, params=params, files=files)

if response.status_code == 200:
print("File uploaded successfully!")
else:
print(f"Error: {response.status_code} - {response.text}")
Make sure you replace YOUR_ACCESS_TOKEN with your actual token and adjust the domain URL if needed. If you still get a 401, double-check your API token and permissions in Workfront.