API upload did not contain a file part
Hello there
I am trying to setup a process allowing me to upload PDFs into Box directly from my PHP app.
When I try to call your API endpoint, I get a 400 error with the message "API upload did not contain a file part".
I double-checked that my file was in the request I sent and I also found some third-party PHP SDK doing things in the same way I did. Yet I still get this error.
My code (using Guzzle) :
$response = $client->post('https://upload.box.com/api/2.0/files/content', [
'headers' => [
'Authorization' => sprintf('Bearer %s', $token['access_token']),
],
'multipart' => [
[
'name' => 'attributes',
'contents' => json_encode([
'name' => sprintf('%s-%s.pdf', $fileName, time()),
'parent' => ['id' => 0],
]),
],
[
'name' => 'file',
'contents' => $file->getContent(),
],
],
]);
I tried reaching your Endpoint directly with cURL, but I get the same result.
Note that $file->getContent() returns the binary PDF directly (that I already have in memory, because I did some processing on them before). In that scenario, I can't use a CurlFile object (like I saw in another post in your support section).
I also tried to generate a Platform App Diagnostics but the CSV is empty.
Any idea on how I can solve my issue ?
Best regards,
Adrien
投稿コメントは受け付けていません。
コメント
2件のコメント