Skip to content

Commit 27b956e

Browse files
committed
OneDrive API: createFolder function fix
1 parent 8a2ab3d commit 27b956e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/OneDrive/DriveItems/DriveItemCollection.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Office365\OneDrive\ConflictBehavior;
99
use Office365\Runtime\Actions\InvokePostMethodQuery;
1010
use Office365\Runtime\ClientRuntimeContext;
11+
use Office365\Runtime\Http\RequestOptions;
12+
use Office365\Runtime\OData\ODataMetadataLevel;
13+
use Office365\Runtime\OData\V4\JsonFormat;
1114
use Office365\Runtime\ResourcePath;
1215
use stdClass;
1316

@@ -32,10 +35,14 @@ public function createFolder($folderName)
3235
$payload = array(
3336
"name" => $folderName,
3437
"folder" => new stdClass(),
35-
"@microsoft.graph.conflictBehavior" => ConflictBehavior::Rename
38+
"@microsoft.graph.conflictBehavior" => ConflictBehavior::Rename,
3639
);
3740
$qry = new InvokePostMethodQuery($this,null,null,null, $payload);
3841
$this->getContext()->addQueryAndResultObject($qry, $folderItem);
42+
$this->getContext()->getPendingRequest()->beforeExecuteRequestOnce(function (RequestOptions $request){
43+
$format = new JsonFormat(ODataMetadataLevel::MinimalMetadata);
44+
$request->Headers["Content-Type"] = $format->getMediaType();
45+
});
3946
return $folderItem;
4047
}
4148

src/Runtime/OData/ODataFormat.php

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
use Office365\Runtime\OData\V3\JsonLightFormat;
8+
use Office365\Runtime\OData\V4\JsonFormat;
89

910
abstract class ODataFormat
1011
{

tests/Settings.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22

33
$secure_vars = explode(";",getenv("phpSPO_secure_vars"));
4-
$parts = explode('@', $secure_vars[0]);
5-
$domain_parts = explode('.', $parts[1]);
6-
$tenant_prefix = $domain_parts[0];
4+
$tenant_prefix = $secure_vars[4];
75

86
return array(
97
'TenantName' => "{$tenant_prefix}.onmicrosoft.com",
@@ -13,8 +11,8 @@
1311
'AdminTenantUrl' => "https://{$tenant_prefix}-admin.sharepoint.com",
1412
'Password' => $secure_vars[1],
1513
'UserName' => $secure_vars[0],
16-
'ClientId' => "4b7eb3df-afc3-4b7d-ae1d-629f22a3fe42",
17-
'ClientSecret' => $secure_vars[2],
14+
'ClientId' => $secure_vars[2],
15+
'ClientSecret' => $secure_vars[3],
1816
'RedirectUrl' => "https://{$tenant_prefix}.sharepoint.com",
1917
'TestAccountName' => "jdoe2@{$tenant_prefix}.onmicrosoft.com",
2018
'TestAltAccountName' => "wellis2@{$tenant_prefix}.onmicrosoft.com"

0 commit comments

Comments
 (0)