Copy pasting this from another question that was never answered:
When I attempt to perform a preflight check with a file with the same name in the same folder and run into a naming collision, I have code that accounts for the conflict error Box API Exception with code: “item_name_in_use”. I expect the JSON object to have an array of conflicts inside context_info as per the documentation https://developer.box.com/reference/resources/conflict-error/
However, sometimes conflicts is an object instead of an array, breaking my deserialization process. Example:
When calling boxFolder.canUpload(filename, fileSize)
, I receive this error:
{
"type": "error",
"status": 409,
"code": "item_name_in_use",
"context_info": {
"conflicts": {
"type": "file",
"id": "1545199568548",
"file_version": {
"type": "file_version",
"id": "1697444235748",
"sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"sequence_id": "0",
"etag": "0",
"sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"name": "20240528_demographics.csv"
}
},
"help_url": "http://developers.box.com/docs/#errors",
"message": "Item with the same name already exists",
"request_id": "1okfwahq6zxgmbxz"
}
Why is ‘conflicts’ sometimes an array and sometimes an object?