Skip to content

Change Folder Owner #567

@c-rei

Description

@c-rei

Hi,
I want to change a folder's owner, so I did it like below.

First I invited the user as a co-owner collaborator on the folder.
Then, update the created collaboration by changing the role of that invited user to owner.


from boxsdk.object.collaboration import CollaborationRole

user = client.user(user_id='11111')
collaboration = client.folder(folder_id='22222').collaborate(user, CollaborationRole.CO-OWNER)
...
...
updated_collaboration = collaboration.update_info(CollaborationRole.OWNER)

I could change the folder's owner, but I've received an error message like below.

####################################################################################
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\util\api_call_decorator.py", line 71, in call
return method(*args, **kwargs)
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\object\collaboration.py", line 61, in update_info
return super(Collaboration, self).update_info(data=data)
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\util\api_call_decorator.py", line 71, in call
return method(*args, **kwargs)
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\object\base_object.py", line 127, in update_info
box_response = self._session.put(url, data=json.dumps(data), params=params, headers=headers, **kwargs)
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\session\session.py", line 121, in put
return self.request('PUT', url, **kwargs)
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\session\session.py", line 157, in request
response = self._prepare_and_send_request(method, url, **kwargs)
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\session\session.py", line 400, in _prepare_and_send_request
self._raise_on_unsuccessful_request(network_response, request)
File "C:\Users\changqli\AppData\Local\anaconda3\envs\py36\lib\site-packages\boxsdk\session\session.py", line 332, in _raise_on_unsuccessful_request
network_response=network_response,
boxsdk.exception.BoxAPIException: Message: Non-json response received, while expecting json response.
Status: 204
Code: None
Request ID: None
Headers: {'Date': 'Tue, 17 Nov 2020 07:31:28 GMT', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000', 'Cache-Control': 'no-cache, no-store', 'BOX-REQUEST-ID': '0fb061c503a0254c8ffa1cc578d68decb'}
URL: https://api.box.com/2.0/collaborations/30601510866
Method: PUT
Context Info: None
####################################################################################
Could you tell me what's wrong with my approach?
Thanks for anything.

Versions Used

Python SDK: 2.6.1
Python: 3.6.10

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions