Create Shared Link in Python
I'm trying to create a shared link for a file -- it returns the file object, so I assume it's working correctly, but the shared_link object in the file object is "none". Any thoughts on this?
params = { 'shared_link':{} } resp = client.make_put_request('https://api.box.com/2.0/files/{fileid}?fields=',params).json() print(resp) class BoxClient(BoxClient): def make_put_request(self, url: str, params: dict = None) -> headers = self._get_headers() return requests.put(url, params=params, headers=headers)
-
The `params` keyword argument in `requests.put()` refers to query string parameters, but the `dict` you construct with `'shared_link': {}` in it needs to be passed via the body (which is called `data` in requests). You should be able to do something like this instead:
import json params = { 'shared_link':{} } resp = client.make_put_request('https://api.box.com/2.0/files/{fileid}?fields=',params).json() print(resp) class BoxClient(BoxClient): def make_put_request(self, url: str, params: dict = None) -> headers = self._get_headers() return requests.put(url, data=json.dumps(params), headers=headers)
Please sign in to leave a comment.
Comments
1 comment