API Docmumentation erroneous / Example lacking or wrong
I was following the API Reference to add a collaboration.
payload = {
"item": {
"type": "folder",
"id": folder_id
},
"accessible_by": {
"type": "user",
"login": "abc@def.com"
},
"role": "viewer",
"notify": "false"
}
headers = {
'Authorization': "Bearer %s" % access_token,
'Content-Type': 'application/json'
}
response = requests.post('https://api.box.com/2.0/collaborations', headers=headers, data=payload)
returns:
{'type': 'error', 'status': 400, 'code': 'bad_request', 'context_info': {'errors': [{'reason': 'invalid_parameter', 'name': 'entity-body', 'message': "Invalid value 'item=type&item=id&accessible_by=type&accessible_by=login&role=viewer&
notify=false'. Entity body should be a correctly nested resource attribute name/value pair"}]}, 'help_url': 'http://developers.box.com/docs/#errors', 'message': 'Bad Request',
'request_id':12345}
-
curl --location --request POST 'https://api.box.com/2.0/collaborations/' \
--header 'Authorization: Bearer token’ \
--header 'Content-Type: text/plain' \
--header 'Cookie: site_preference=desktop' \
--data-raw '{"item": { "id": “folder”, "type": "folder"}, "accessible_by": { "login": “email@gmail.com"}, "role": "editor"}'Might be something off in the formatting of the command given the error. The above worked for me in curl
I was also able to add collaboration in Postman.
サインインしてコメントを残してください。
コメント
1件のコメント