Skip to main content
Question

Create upload session get error HTTP 415

  • May 22, 2025
  • 5 replies
  • 60 views

Forum|alt.badge.img

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

5 replies

Forum|alt.badge.img

What is the folder_id, file_size, and file_name?


Forum|alt.badge.img

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


Forum|alt.badge.img

I found some post where the lack of extension would cause the 415 error, but that's not the case for you.

I'm actually getting that error too. I happen to be using golang, although it works on the curl command line following their example.


Forum|alt.badge.img

Hi,

Does anyone has an idea, please?

Thank you


Forum|alt.badge.img

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.