microsoftgraph / msgraph-sdk-php

Microsoft Graph Library for PHP.
Other
568 stars 144 forks source link

V2 Impossible to patch or post folder drive item #1461

Open flohw opened 7 months ago

flohw commented 7 months ago

Hi again,

Sorry for two issues in a row...

I had a method to rename a drive item. I used to call $graph->createRequest('PATCH', 'drives/{drive-id}/items/{drive-item-id}')->attachBody(json_encode(['name' => 'new name']))->execute(); to rename a drive item.

I saw the new method with the v2 which seems to be :

/** @var DriveItemRequestBuilder $drive */
$driveItem = $drive->items()->byDriveItemId('{drive-item-id}')->get()->wait();
// Same result with $driveItem = new DriveItem(); $driveItem->setName('new name');
$drive->items()->byDriveItemId('{drive-item-id}')->patch($driveItem)->wait();

But I get an exception with the only indication : Invalid request which is not really useful... I have a ClientCredentialCertificateContext and I used to authenticate with that same certificate method. I do not provide any scopes and I didn't provide any before either.

Let me know if I can provide more information. I don't really know where to look.

Thanks for your help.

I don't know where to look, the resources about that are limited and

[EDIT]: In the meantime, I tried to create a directory and I faced the same issue as described here: https://stackoverflow.com/questions/77601341/ms-graphapi-php-sdk-fails-creating-a-new-folder

[EDIT BIS]: I also tried to migrate the api calls to contacts endpoint (POST users/{user-id}/contactFolders/{contact-folder-id}/contactswith $graph->users()->byUserId('{user-id}')->contactFolders()->byContactFolderId('{contact-folder-id}')->contacts()->post($newContact, $configuration)->wait() the configuration only has the header ['Prefer' => 'IdType="ImmutableId"'] the thrown errors could not serialize payload. I don't undersand what I am doing wrong in the process... Any help would be appreciated.

SteveSplitHands commented 6 months ago

I am facing the same issues with application permissions using client secret route. I tried doing the directory creation I needed in a throwaway C# console app and it worked perfectly, so despite it being a error response from server it appears to be something wrong with how php client is sending request.

If I have time later this week I'll try and pull out a network sniffer to catch the requests and see if I can find the difference between my throwaway C# app and my php code.