Skip to main content
Question

File Upload issue Using API

  • May 22, 2025
  • 4 replies
  • 48 views

Forum|alt.badge.img

Hi - I am trying to upload a file using php WEB API, please let me know what am I doing wrong in the below code.
$params = {"file":{"name":"\/home\/projsnap\/public_html\/artwork\/wp-content\/uploads\/2022\/02\/PSNAP-PoqAOGtSk6.jpeg","mime":"","postname":"PSNAP-PoqAOGtSk6.jpeg"},"name":"PSNAP-PoqAOGtSk6.jpeg","parent_id":"115643781052","access_token":"XaMcjFobU7b3egPcD7ndifBkT4RFbq5u"}

  $params = array('file' => $file, 'name' => $name, 'parent_id' => $parent_id, 'access_token' => $this->access_token);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;


 I am getting below error -


{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"parent","message":"Invalid value 'd_115643781052'. 'parent' with value 'd_115643781052' not found"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Not Found","request_id":"4rf8g4gz65g9qhey"}

4 replies

Forum|alt.badge.img

The not found error typically occurs when the application doesn't have access to the folder you're trying to upload content into.... have you collaborated the application's service account into the folder? Assuming you are using our JWT app type... 

 

Alex, Box Developer Advocate


Forum|alt.badge.img

Hello Alex Novotny 

We are using the OAuth 2.0 (User or Client Authentication) app type. Also we provided folder access. Please check the screenshot. http://prntscr.com/26wt1gs


Forum|alt.badge.img

So that setting simply provides access to the currently authenticated user's folder tree.... does the user who signs into the application have access to the folder you are looking for? 


Forum|alt.badge.img

Hello Alex Novotny

Yes all the folder has been created by the same user. and Also the user sign in the application. We are using the access token to upload the files and created a folder. Previously it was working fine. The issue comes in last 15 days.