Some missing fluent API paths e.g. /me/drive/root/content
Missing paths should have an alternative URL path that is supported. You can find alternative paths from our API Reference
Hi @Ndiritu, I'm trying to upgrade from RC4 to RC5 and I'm stuck with rewriting code for creating new UploadSession. Before update, I was creating the upload session this way:
/** @var UploadSession $driveItemUpload */
$driveItemUpload = $graph->createRequest('POST', '/drives/b!JAGSss-y9Uio20iGLHPPKbk_lZ1tsSxDijzVQZqZpmm_W6DxtFZNS5VR-gtQPhls/root/children/test-file.pdf/createUploadsession')
->attachBody([
'item' => (object) [
'@microsoft.graph.conflictBehavior' => 'replace',
],
])
->setReturnType(UploadSession::class)
->execute();
but the proper fluent API class in the RC5 seems to be missing:
$request = $graph->drivesById('b!JAGSss-y9Uio20iGLHPPKbk_lZ1tsSxDijzVQZqZpmm_W6DxtFZNS5VR-gtQPhls')
->root()
->childrenById('test-file.pdf')
->createUploadSession(); // <-- missing
Is the uploadSession method also missing or should I create upload session differently?
@hubipe thanks for highlighting that missing path.
I tried to create the URL path based on the first path
The closest workaround I could come up with was:
$rootDriveId = 'b!JAGSss-y9Uio20iGLHPPKbk_lZ1tsSxDijzVQZqZpmm_W6DxtFZNS5VR-gtQPhls';
$itemId = 'root:/test-file.pdf:';
$itemProperties = new DriveItemUploadableProperties();
$itemProperties->setAdditionalData(['@microsoft.graph.conflictBehavior' => 'replace']);
$body = new CreateUploadSessionPostRequestBody();
$body->setItem($itemProperties);
$session = $graphServiceClient->drivesById($rootDriveId)->itemsById($driveItemId)->createUploadSession()->post($body)->wait();
Let me know if it works
For the missing paths there's usually an alternative URL path from the docs that's supported, although we should support all.
Hi @Ndiritu, thanks for the workaround. Unfortunately that does not work as the Graph API returns invalid request.
The library generates POST request to https://graph.microsoft.com/v1.0/drives/b%21JAGSss-y9Uio20iGLHPPKbk_lZ1tsSxDijzVQZqZpmm_W6DxtFZNS5VR-gtQPhls/items/root%3Atest-file.pdf/microsoft.graph.createUploadSession
with JSON body:
{
"item": {
"@microsoft.graph.conflictBehavior": "replace"
}
}

However you made a good point that itemsById() method also receives the path in the „colon“ notation,. So instead of
$itemId = 'root:test-file.pdf';
I used
$itemId = 'root:/test-file.pdf:';
and miraculously enough, that works:

So thank you very much
You're welcome, feel free to share feedback on your overall experience with this version. What works well? What don't you like? What can we improve? Preferrably on the announcement post https://github.com/microsoftgraph/msgraph-sdk-php/issues/943
The convention for alternative paths shall be to access resources from their root e.g. for Drive, using drive/... endpoints etc to minimize SDK size