Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Create Shared Link in Python

New post

Comments

1 comment

  • mwiller

     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) 
    0
    Comment actions Permalink

Please sign in to leave a comment.