Skip to content

Commit

Permalink
OneDrive API: createFolder function fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Mar 3, 2023
1 parent 8a2ab3d commit 27b956e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/OneDrive/DriveItems/DriveItemCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Office365\OneDrive\ConflictBehavior;
use Office365\Runtime\Actions\InvokePostMethodQuery;
use Office365\Runtime\ClientRuntimeContext;
use Office365\Runtime\Http\RequestOptions;
use Office365\Runtime\OData\ODataMetadataLevel;
use Office365\Runtime\OData\V4\JsonFormat;
use Office365\Runtime\ResourcePath;
use stdClass;

Expand All @@ -32,10 +35,14 @@ public function createFolder($folderName)
$payload = array(
"name" => $folderName,
"folder" => new stdClass(),
"@microsoft.graph.conflictBehavior" => ConflictBehavior::Rename
"@microsoft.graph.conflictBehavior" => ConflictBehavior::Rename,
);
$qry = new InvokePostMethodQuery($this,null,null,null, $payload);
$this->getContext()->addQueryAndResultObject($qry, $folderItem);
$this->getContext()->getPendingRequest()->beforeExecuteRequestOnce(function (RequestOptions $request){
$format = new JsonFormat(ODataMetadataLevel::MinimalMetadata);
$request->Headers["Content-Type"] = $format->getMediaType();
});
return $folderItem;
}

Expand Down
1 change: 1 addition & 0 deletions src/Runtime/OData/ODataFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


use Office365\Runtime\OData\V3\JsonLightFormat;
use Office365\Runtime\OData\V4\JsonFormat;

abstract class ODataFormat
{
Expand Down
8 changes: 3 additions & 5 deletions tests/Settings.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

$secure_vars = explode(";",getenv("phpSPO_secure_vars"));
$parts = explode('@', $secure_vars[0]);
$domain_parts = explode('.', $parts[1]);
$tenant_prefix = $domain_parts[0];
$tenant_prefix = $secure_vars[4];

return array(
'TenantName' => "{$tenant_prefix}.onmicrosoft.com",
Expand All @@ -13,8 +11,8 @@
'AdminTenantUrl' => "https://{$tenant_prefix}-admin.sharepoint.com",
'Password' => $secure_vars[1],
'UserName' => $secure_vars[0],
'ClientId' => "4b7eb3df-afc3-4b7d-ae1d-629f22a3fe42",
'ClientSecret' => $secure_vars[2],
'ClientId' => $secure_vars[2],
'ClientSecret' => $secure_vars[3],
'RedirectUrl' => "https://{$tenant_prefix}.sharepoint.com",
'TestAccountName' => "jdoe2@{$tenant_prefix}.onmicrosoft.com",
'TestAltAccountName' => "wellis2@{$tenant_prefix}.onmicrosoft.com"
Expand Down

0 comments on commit 27b956e

Please sign in to comment.