Create upload session get error HTTP 415
Hi,
I am trying to create an upload session (using PHP curl), but get an error 415. Can anyone help, please?
Here are what my curl options looks like:
CURLOPT_HTTPHEADER => array('Authorization: Bearer '.$token, 'Content-Type: application/json'),
CURLOPT_URL => 'https://upload.box.com/api/2.0/files/upload_sessions/',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(array(
'folder_id' => $folder_id,
'file_size' => $file_size,
'file_name' => $file_name,
)),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_CAINFO => 'cacert.pem'
Thank you
-
Hi,
For the folder_id I used 0, like in the documentation (https://developer.box.com/reference/post-files-upload-sessions/) to send to the root of my Box, the file_size is my file size (133153433) and file_name my file name (test.tar.gz).
Thank you
-
In case someone else have this issue, here is what I changed on my curl:
CURLOPT_HTTPHEADER => array('Authorization: Bearer '.$token, 'Content-Type: application/json'),
CURLOPT_URL => 'https://upload.box.com/api/2.0/files/upload_sessions',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => '{
"folder_id": "'.$id_file_destination.'",
"file_size": '.$total_file_size.',
"file_name": "'.$name.'"
}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_CAINFO => 'cacert.pem'No slash at the end of the url and no comma after the file name.
サインインしてコメントを残してください。
コメント
5件のコメント