I'm trying to update file info with Box API in PHP

    down vote


I must to modify the name of the file’s box sometimes, I have the cUrl request but I can’t write it in PHP.
The cUrl is:

  curl https://api.box.com/2.0/files/FILE_ID \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -d '{"name":"new name.jpg"}' \
  -X PUT

But how can I do with the -d flag?

I using Guzzle (request of my boss…).

I have problem with this part of my code:


Someone can help me?


Not the expert on Guzzle…

Though it looks like the setPostField() function is for a single field and it looks like you are filling it with multiple attributes/ fields, if I can believe the pluralization of the variable. :smile:

Have you tried the setBody() function with put()?

I have no idea if this is even close to what you need.

$httpRequest = $client->put('https://api.box.com/2.0/files/FILE_ID')
    ->setHeader('Authorization', ACCESS_TOKEN) 
    ->setBody(json_encode($attributes), 'application/json');

Also, have you looked at this Box PHP SDK?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.