Skip to content

Non-JSON response received exception on collaboration.update_info() #528

@supermitch

Description

@supermitch

Description of the Issue

When I try to call update_info on a collaboration, the SDK throws an exception, although the call succeeds.
The method I'm using: https://github.com/box/box-python-sdk/blob/master/docs/usage/collaboration.md#edit-a-collaboration

Steps to Reproduce

I am attempting to set a new owner on a folder, according to: https://developer.box.com/guides/folders/single/change-owner/
Note that this WORKS as intended. The post to update_info is succeeding, it is the response
that fails.

My code:

    config = conf.load_config('box_search.py')
    bc = box.BoxClient()  # My own thin client wrapper
    target_name = 'target.last'
    owner_name = 'owner.last'
    FOLDER_ID = 1188722345
    owner = bc.get_user(owner_name)
    user_client = bc.get_user_client(owner.id)
    src_folder = user_client.folder(FOLDER_ID)
    target = bc.get_user(target_name)
    print('Adding collab')
    src_collab = src_folder.collaborate(target, CollaborationRole.EDITOR)
    print('Updated collab')
    _ = src_collab.update_info(CollaborationRole.OWNER)  # Throws Exception!
    print('Checking collab')
    collaborations = src_folder.get_collaborations()
    for collab in collaborations:
        target = collab.accessible_by
        if target.id == owner.id:
            collab.delete()

Expected Behavior

I expect it to return a new collaboration object, since the call is succeeding. I confirmed many times the ownership is transferred successfully.

The API is returning a 204 instead of a 200, which seems to be breaking the SDK.

Error Message, Including Stack Trace

Adding collab
Updated collab
Traceback (most recent call last):
  File "./box_reorg_test.py", line 43, in <module>
    main()
  File "./box_reorg_test.py", line 33, in main
    _ = src_collab.update_info(CollaborationRole.OWNER)
  File "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/site-packages/boxsdk/util/api_call_decorator.py", line 71, in call
    return method(*args, **kwargs)
  File "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/site-packages/boxsdk/object/collaboration.py", line 61, in update_info
    return super(Collaboration, self).update_info(data=data)
  File "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/site-packages/boxsdk/util/api_call_decorator.py", line 71, in call
    return method(*args, **kwargs)
  File "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/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 "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/site-packages/boxsdk/session/session.py", line 121, in put
    return self.request('PUT', url, **kwargs)
  File "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/site-packages/boxsdk/session/session.py", line 157, in request
    response = self._prepare_and_send_request(method, url, **kwargs)
  File "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/site-packages/boxsdk/session/session.py", line 400, in _prepare_and_send_request
    self._raise_on_unsuccessful_request(network_response, request)
  File "/Users/my_username/workspace/box-scripts/venv/lib/python3.7/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': 'Mon, 27 Jul 2020 23:16:54 GMT', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000', 'Cache-Control': 'no-cache, no-store', 'BOX-REQUEST-ID': '065305bafe80ff3870567b8c931b5d5aa'}
URL: https://api.box.com/2.0/collaborations/27688108163
Method: PUT
Context Info: None

Versions Used

Python SDK: boxsdk 2.6.0
Python: 3.7.2

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions