PUT file data to a Autodesk API with Python Requests

蓝咒 提交于 2019-12-02 16:35:08

问题


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"}

回答1:


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



来源:https://stackoverflow.com/questions/46699226/put-file-data-to-a-autodesk-api-with-python-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!