Python upload script
This does not work with box sdk on python
Traceback (most recent call last):
File "p_box_test.py", line 12, in <module>
new_file = client.folder(folder_id).upload.upload('test.txt')
AttributeError: module 'boxsdk.client.client' has no attribute 'folder'
when i change the "client" to "Client" then i get this:
Traceback (most recent call last):
File "p_box_test.py", line 12, in <module>
new_file = Client.folder(folder_id).upload.upload('test.txt')
TypeError: folder() missing 1 required positional argument: 'folder_id'
Before you start showing off your intelectual superiority by telling me to read the development SDK again, i am working just fine with Trello, Slack and Ansible API using Python, and i do not want to stampede to start a more colloquial terms. Thanks in advance for helping me out.
-
Curl does not work as well, what credentials should i use here?
https://developer.box.com/guides/uploads/direct/file/curl -i -X POST "https://upload.box.com/api/2.0/files/content" -H "Authorization: Bearer ???????????????? " -H "Content-Type: multipart/form-data" -F attributes='{"name":"test.txt", "parent":{"id":"159248921121"}}' -F file=@test.txt
With Ansible or Trello it's easy, i just put my Oauth2 token, but here? I tried my apps developer token.
HTTP/1.1 403 Forbidden
Date: Fri, 25 Mar 2022 12:25:53 GMT
Content-Length: 0
Connection: keep-alive
WWW-Authenticate: Bearer realm="Service", error="insufficient_scope", error_description="The request requires higher privileges than provided by the access token."
X-Envoy-Upstream-Service-Time: 189
Strict-Transport-Security: max-age=31536000 -
Jozef,
In your curl example you can use a bearer token which is the access token. You can grab that from Box developer console. See https://developer.box.com/guides/authentication/tokens/developer-tokens or from https://developer.box.com/reference/post-oauth2-token/
In Python SDK, I see 2 upload (new_file = client.folder(folder_id).upload.upload('test.txt')
) not sure if that is a typo. If you can provide the complete file then I can run it in my environment and try to see the issue. You can upload it to Box and provide a link or I can raise a File request for you.Thanks
Rohit
投稿コメントは受け付けていません。
コメント
3件のコメント