msgraph-sdk-php
msgraph-sdk-php copied to clipboard
Drive – create upload session does not work since @RC6
Hi, since 2.0.0-RC6 creating upload session stopped to work. Here is a code sample, which used to work until RC5:
use Microsoft\Graph\Generated\Drives\Item\Items\Item\CreateUploadSession\CreateUploadSessionPostRequestBody;
use Microsoft\Graph\Generated\Models\DriveItemUploadableProperties;
$itemProperties = new DriveItemUploadableProperties();
$itemProperties->setAdditionalData([
'@microsoft.graph.conflictBehavior' => 'replace',
]);
$body = new CreateUploadSessionPostRequestBody();
$body->setItem($itemProperties);
$session = $graph->drivesById($driveId)
->itemsById('root:/test-file.pdf:')
->createUploadSession()
->post($body)
->wait();
The graph API returns HTTP 400 Bad Request.
The problem is within a body of the request. Until the RC5, the request body was:
{
"item": {
"@microsoft.graph.conflictBehavior":"replace"
}
}

but since RC6 the request body is:
{
"item": {
"@odata.type": "#microsoft.graph.driveItemUploadableProperties",
"@microsoft.graph.conflictBehavior": "replace"
}
}

It seems, that Graph API does not understand the @odata.type item property. Is it necessary to include the @odata.type property?