An API that connects multiple Microsoft services, enabling data access and automation across platforms
Microsoft does not document a OneDrive Personal guarantee that a 204 No Content from DELETE prevents an already concurrent final PUT from committing, nor that a destination-item 404 Not Found proves the item cannot appear afterward.
What the documented responses establish
- With
deferCommitomitted orfalse, receiving the final byte range automatically completes the upload. A successful finalPUTreturns200 OKor201 Createdand the completeddriveItemmetadata. ^1^ -
DELETE uploadUrlcancels the session and cleans up the temporary file; its documented success response is204 No Content. The documentation does not define serialization or precedence between thatDELETEand a finalPUTalready being processed. ^1^ - A
404from the upload-session URL means that the upload session no longer exists, and the documented recovery is to start the upload again. That is different from a404when looking up the destination path: the latter only reports that no matching item was returned by that lookup. ^1^ - If an upload request disconnects or fails before the request is completed, all bytes from that request are ignored. This does not cover a request that the service completed when only its response was lost. ^1^
Consequently, neither the DELETE 204 nor an immediately following destination 404 is a documented proof that the racing final PUT cannot subsequently be observed as committed.
Handling a lost or timed-out final response
Treat the result as ambiguous rather than automatically retrying the entire upload:
- Query the upload URL with
GET.-
200 OKwithnextExpectedRangesmeans the session still exists and identifies missing data. -
404 Not Foundmeans the session no longer exists. It does not distinguish, by itself, between cancellation and prior successful completion.
-
- Look up the destination item and validate its identity. Do not rely only on the path existing. Compare the returned item ID and relevant properties such as name and size with the intended upload.
- If neither request establishes success, record an indeterminate outcome.
The published v1.0 contract provides no transaction-status or cancellation-fence operation that proves the final
PUTlost the race. - Avoid blindly replaying the full operation under
replaceorrename. Depending on conflict behavior, that can overwrite an item or create another item rather than resolve whether the first operation committed.
Microsoft recommends retrying interrupted uploads and 5xx responses, using exponential backoff for 5xx errors. That retry guidance does not make a timed-out final commit exactly-once. ^1^
Reduce the race with deferCommit
For new sessions, set deferCommit to true. Uploading the final byte then does not create the destination file until an explicit completion request is made:
POST /me/drive/items/{parentId}:/{fileName}:/createUploadSession
Content-Type: application/json
{
"item": {
"@microsoft.graph.conflictBehavior": "fail"
},
"deferCommit": true
}
For OneDrive Personal, explicit completion is performed with a final PUT; the zero-length POST completion method is documented only for OneDrive for Business and SharePoint. ^1^
This separates byte transfer from publication and lets the application cancel before initiating commit. It does not provide a documented ordering guarantee once the explicit commit PUT and DELETE are concurrent. Enforce application-level coordination so only one process can begin either operation for a session—for example, atomically transition a shared session record from uploading to either committing or cancelling.
For a contractual guarantee stronger than this published behavior, the required next step is a Microsoft support request containing timestamps, request IDs, the OneDrive Personal account type, and sanitized request/response traces; the public Graph v1.0 documentation does not specify stronger race semantics.
References