FOLDER CREATION
HI Every one ,
I used the following code to create folders with box API
function creatFolder($folderName){
echo $folderName;
$params = [
'name' => $folderName,
'parent' => array('id'=>'0')
];
$response = $this->client->request('POST',$this->folUrl, [
'form_params' => $params
]);
$data = $response->getBody()->getContents();
}
Here I am using GuzzleHttp\Client client to post the request
post URL is
$this->folUrl = "https://api.box.com/2.0/folders";
-
You need an access token and you also need to send the post data in json format.
The following worked for me:
$parent = array();
$parent['id'] = $parent_id;
$params = array();
$params['name'] = $name;
$params['parent'] = $parent;
$params = json_encode($params);
$results = $this->httpClient->request('POST', 'https://api.box.com/2.0/folders',
[
'headers' => [
'Authorization' => 'Bearer ' . $access_token,
'Content-type: application/json'],
'body' => $params,
]);
投稿コメントは受け付けていません。
コメント
1件のコメント