Upload a New Version of a File method of box api in php not working
here is the code that I use to send request
$uploadfile =$_SESSION['uploadfile'];
$fileid =$_SESSION['fileid'];
$myuri='https://upload.box.com/api/2.0/files/'.$fileid.'/content';
$curl2 = curl_init();
curl_setopt($curl2, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$_SESSION['usertoken']));
curl_setopt_array($curl2, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $myuri,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
filename => "@".$uploadfile
)
));
// Send the request & save response to $resp
$data = curl_exec($curl2);
$data = json_decode($data);
I get the following error response back from box:
object(stdClass)#1 (7) { ["type"]=> string(5) "error" ["status"]=> int(400) ["code"]=> string(11) "bad_request" ["context_info"]=> object(stdClass)#2 (1) { ["errors"]=> array(1) { [0]=> object(stdClass)#3 (3) { ["reason"]=> string(17) "missing_parameter" ["name"]=> string(6) "parent" ["message"]=> string(20) "'parent' is required" } } } ["help_url"]=> string(38) "http://developers.box.com/docs/#errors" ["message"]=> string(11) "Bad Request" ["request_id"]=> string(23) "1638286030525d1c87c6a1e" }
according to their documentation i only need the file name of the file i am trying to upload and file Id of the file i am trying to overwrite it says nothing about requiring a parent what am I missing here? Is this a bug or is the documentation wrong?
the documentation can be found here http://developers.box.com/docs/#files-upload-a-new-version-of-a-file