ERROR: invalid_parameter -{"reason":"invalid_parameter","name":"parent","message":"Invalid value 'd_**********'. 'parent' with value 'd_**********' not found"}]
AnsweredHi I am using php curl request to upload file to the box, I have tried many different package and methods but every time I am getting same error on file upload. Request response details is as below -
string(324) "{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"parent","message":"Invalid value 'd_154533439669'. 'parent' with value 'd_154533439669' not found"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Not Found","request_id":"b474svgylf4y35hk"}"
Here is my code for the request -
$curl = curl_init();
$url = 'https://upload.box.com/api/2.0/files/content';
curl_setopt($curl,CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$access_token,
'Content-Type: multipart/form-data'
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array('attributes' => '{"name": "'.$this->fileName.'", "parent": {"id": "'.$this->folderId.'"}}','file'=> new CURLFILE((string) $fileFullpath, 'text/csv', $this->fileName)) );
$response = curl_exec($curl);
curl_close($curl);
echo '<pre>';
var_dump($response);
Let me know if I am missing anything or doing anything wrong.
-
Hi Amber
Are you using a JWT or Client Credentials Grant application?
If this is the case then the token you use is most likely from the service account of the app, and it could be that the folder you are trying to upload to is only accessible by your standard user
- the user you login to box.com as.
To confirm which user the token belongs to try the below API with your token
https://developer.box.com/reference/get-users-me/To confirm if that user has access to the folder try this API with your token
https://developer.box.com/reference/get-folders-id
To get a token for your standard user you can either use the As-User header
https://developer.box.com/guides/authentication/jwt/as-user/Or generate a token for the user who needs to upload the file
https://developer.box.com/guides/authentication/jwt/user-access-tokens/Best regards
Peter Christensen, Platform Solutions Engineer, Box
Post is closed for comments.
Comments
2 comments