Tom
Tom

Reputation: 22841

PUT file data to a Autodesk API with Python Requests

I am following the process described here but getting stopped by a 403 at Step 4. I have a token with data:write and data:create scopes as specified in the docs (and other API methods needing those scopes work) but I can't get a successful response and I think it's down to how I am sending the file data. My code looks like this:

url = '{}oss/v2/buckets/{}/objects/{}'.format(self.DOMAIN, bucket_id, object_name)
with open(file_path, 'rb') as f:
    file_content = f.read()
response = self.session.put(url, data=file_content, headers={
    'content-type': 'application/octet-stream'
}

The auth token is already included in the session's headers. Here are the logs from the upload process:

INFO Creating storage for README.md file in Test Project project, folder urn:adsk.wipprod:fs.folder:co.XXXXXXXXXXXXXXXX
INFO Storage success, start PUT file to https://developer.api.autodesk.com/oss/v2/buckets/:wip.dm.prod/objects/eb0e0379-9958-45b5-8bb0-5f4111b7a037.md
WARNING Upload failed, status 403: {"developerMessage":"ACM check failed, user or calling service does not have access to perform this operation","userMessage":"","errorCode":"AUTH-012","more info":"http://developer.api.autodesk.com/documentation/v1/errors/AUTH-012"}

Upvotes: 0

Views: 410

Answers (1)

Xiaodong Liang
Xiaodong Liang

Reputation: 2206

We had a sample code with Python in the past with v1 endpoints. I migrated to v2 today. It looks working well. Could you take a look if it could help you to address the issue you are having? https://github.com/xiaodongliang/forge.workflow-python-sample

Upvotes: 1

Related Questions