Hi,
I'm using the MS Graph API and one of my tasks is to create a new folder on my OneDrive.
The MS documentation says the message body should be like this:
Code:
{
"name": "New Folder",
"folder": { },
"@microsoft.graph.conflictBehavior": "rename"
}Using the code below, I have tried to state 'folder'=>[], 'folder'=>array, 'folder'=>{}, 'folder'=>'{}' and so on
PHP Code:
$client->POST('drives/'.env('msgraph.driveid').'/items/'.env('msgraph.projectfolder.id').'/children',
[
'headers' => [
'Authorization' => $access_token,
'Content-Type' => 'application/json',
],
'json'=>[
'name'=>$MS_Values,
'folder'=>,
'@microsoft.graph.conflictBehavior'=>'rename'
],
],
);
PHP Code:
$empty=[];
$empty= json_encode($empty, JSON_FORCE_OBJECT);
$client->POST('drives/'.env('msgraph.driveid').'/items/'.env('msgraph.projectfolder.id').'/children',
[
'headers' => [
'Authorization' => $access_token,
'Content-Type' => 'application/json',
],
'json'=>[
'name'=>$MS_Values,
'folder'=>$empty,
'@microsoft.graph.conflictBehavior'=>'rename'
],
],
);
Any help, is appreciated, this is driving me mad !!!
Hi All,
Eventually I have got this to work.
Code:
$client->POST('drives/'.env('msgraph.driveid').'/items/'.env('msgraph.projectfolder.id').'/children',
[
'headers' => [
'Authorization' => $access_token,
'Content-Type' => 'application/json',
],
'json'=>[
'name'=>$MS_Values,
'folder'=>['json'=>""],
'@microsoft.graph.conflictBehavior'=>'rename'
],
],
);