onedrive-api-docs: ODP | ODB: /createUploadSession If-Match should not generate a 412 Precondition Failed when the exact online eTag is being used
Category
- Question
- Documentation issue
- Bug
Expected or Desired Behavior
When using a session to upload a modified file, the API should not present a 412 Precondition Failed error when using If-Match and the provided eTag equals the existing online eTag.
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession
Observed Behavior
- Query the exact file item online to get the absolute latest eTag item, compare against current known value
- Attempt to create an upload session via
/createUploadSessionand add theIf-Matchheader with the known eTag value - Get a 412 response from OneDrive API
[DEBUG] Setting file permissions for: /home/alex/.config/onedrive/refresh_token
[DEBUG] Request URL = https://graph.microsoft.com/v1.0/drives/66d53be8a5056eca/root:/4mb_word_doc%2FH2A%20Research%20Equivalence%20v6.docx
* Trying 20.190.142.172...
* Connected to graph.microsoft.com (20.190.142.172) port 443 (#1)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; CN=graph.microsoft.com
* start date: Jun 28 00:00:00 2023 GMT
* expire date: Jun 28 23:59:59 2024 GMT
* subjectAltName: host "graph.microsoft.com" matched cert's "graph.microsoft.com"
* issuer: C=US; O=DigiCert Inc; CN=DigiCert SHA2 Secure Server CA
* SSL certificate verify ok.
> GET /v1.0/drives/66d53be8a5056eca/root:/4mb_word_doc%2FH2A%20Research%20Equivalence%20v6.docx HTTP/1.1
Host: graph.microsoft.com
User-Agent: ISV|abraunegg|OneDrive Client for Linux/v2.5.0-dev
Accept: */*
Authorization: bearer <Redacted>
< HTTP/1.1 200 OK
< Cache-Control: no-store
< Transfer-Encoding: chunked
< Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
< Strict-Transport-Security: max-age=31536000
< request-id: a0d14097-1ff0-4889-a028-ba2c5a98e780
< client-request-id: a0d14097-1ff0-4889-a028-ba2c5a98e780
< x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Australia Southeast","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":"ML1PEPF00004F6B"}}
< OData-Version: 4.0
< Date: Mon, 31 Jul 2023 06:26:14 GMT
<
[DEBUG] onedrive.performHTTPOperation() => OneDrive HTTP Server Response: 200
* Connection #1 to host graph.microsoft.com left intact
[DEBUG] curlEngine.http.perform() => HTTP Response Headers: ["strict-transport-security":"max-age=31536000", "x-ms-ags-diagnostic":"{\"ServerInfo\":{\"DataCenter\":\"Australia Southeast\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"000\",\"RoleInstance\":\"ML1PEPF00004F6B\"}}", "transfer-encoding":"chunked", "odata-version":"4.0", "date":"Mon, 31 Jul 2023 06:26:14 GMT", "client-request-id":"a0d14097-1ff0-4889-a028-ba2c5a98e780", "request-id":"a0d14097-1ff0-4889-a028-ba2c5a98e780", "cache-control":"no-store", "content-type":"application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"]
[DEBUG] OneDrive API Response: {"@microsoft.graph.downloadUrl":"https:\/\/mwg7ww.ph.files.1drv.com\/y4mo9rtLgLlSUh88_XuyOnu9UVYuvrcfHwi_1e1dviDdiM_NMmWNsSvmjTZ0Hb6wp4tB0bjS18DFsL5naN9IkHcc30D-v9RUiQw6jR1thO8Ry4frPbDm7sDklS8P6oOy7mG7PulwuLMbiOkUfFtUvnQLuHoLI2MChDgk4e71BTVWaQuyusyTdSRsSyH9dHp9NZPfiY0ws9CTnRBDwR56Mm1tnz0Y2z9ytY1PVjOHyjZVIE","@odata.context":"https:\/\/graph.microsoft.com\/v1.0\/$metadata#drives('66d53be8a5056eca')\/root\/$entity","cTag":"aYzo2NkQ1M0JFOEE1MDU2RUNBITI4NTA1Mi4xOTM1","createdBy":{"application":{"displayName":"OneDrive Client for Linux","id":"4035b959"},"user":{"displayName":"SADF ASDF","id":"66d53be8a5056eca"}},"createdDateTime":"2023-07-31T05:40:17.047Z","eTag":"aNjZENTNCRThBNTA1NkVDQSEyODUwNTIuOQ","file":{"hashes":{"quickXorHash":"Ml4zGCvJpAyqzLM5FaZWhpGLqs0=","sha1Hash":"310BE58EFA885921A012FD84D35313FB371F35FF","sha256Hash":"E7D28D034AE2233450267A9DD39AFD9EDD1FB785459575C55D7FEE4E6DE39FE9"},"mimeType":"application\/vnd.openxmlformats-officedocument.wordprocessingml.document"},"fileSystemInfo":{"createdDateTime":"2023-07-31T05:40:17.046Z","lastModifiedDateTime":"2023-07-31T05:41:33.956Z"},"id":"66D53BE8A5056ECA!285052","lastModifiedBy":{"user":{"displayName":"SADF ASDF","id":"66d53be8a5056eca"}},"lastModifiedDateTime":"2023-07-31T05:41:37.05Z","name":"H2A Research Equivalence v6.docx","parentReference":{"driveId":"66d53be8a5056eca","driveType":"personal","id":"66D53BE8A5056ECA!285051","name":"4mb_word_doc","path":"\/drive\/root:\/4mb_word_doc"},"reactions":{"commentCount":0},"size":4316411,"webUrl":"https:\/\/1drv.ms\/w\/s!AMpuBaXoO9VmkbJ8"}
[DEBUG] dbItem.eTag: aNjZENTNCRThBNTA1NkVDQSEyODUwNTIuOQ
[DEBUG] currentOnlineData eTag: aNjZENTNCRThBNTA1NkVDQSEyODUwNTIuOQ
* Found bundle for host graph.microsoft.com: 0x1c0c270 [can pipeline]
* Re-using existing connection! (#1) with host graph.microsoft.com
* Connected to graph.microsoft.com (20.190.142.172) port 443 (#1)
> POST /v1.0/drives/66d53be8a5056eca/items/66D53BE8A5056ECA!285052:/H2A%20Research%20Equivalence%20v6.docx:/createUploadSession HTTP/1.1
Host: graph.microsoft.com
User-Agent: ISV|abraunegg|OneDrive Client for Linux/v2.5.0-dev
Accept: */*
If-Match: aNjZENTNCRThBNTA1NkVDQSEyODUwNTIuOQ
Content-Type: application/json
Authorization: bearer <Redacted>
Content-Length: 110
* We are completely uploaded and fine
< HTTP/1.1 412 Precondition Failed
< Cache-Control: no-store
< Transfer-Encoding: chunked
< Content-Type: application/json
< Strict-Transport-Security: max-age=31536000
< request-id: 1db71ddc-ae37-4563-8e1f-a136d065e35c
< client-request-id: 1db71ddc-ae37-4563-8e1f-a136d065e35c
< x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Australia Southeast","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":"ML1PEPF00004F6B"}}
< Date: Mon, 31 Jul 2023 06:26:14 GMT
<
[DEBUG] onedrive.performHTTPOperation() => OneDrive HTTP Server Response: 412
* Connection #1 to host graph.microsoft.com left intact
[DEBUG] curlEngine.http.perform() => HTTP Response Headers: ["strict-transport-security":"max-age=31536000", "x-ms-ags-diagnostic":"{\"ServerInfo\":{\"DataCenter\":\"Australia Southeast\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"000\",\"RoleInstance\":\"ML1PEPF00004F6B\"}}", "transfer-encoding":"chunked", "date":"Mon, 31 Jul 2023 06:26:14 GMT", "client-request-id":"1db71ddc-ae37-4563-8e1f-a136d065e35c", "request-id":"1db71ddc-ae37-4563-8e1f-a136d065e35c", "cache-control":"no-store", "content-type":"application/json"]
[DEBUG] Exit scope called
onedrive.OneDriveException@src/onedrive.d(1154): HTTP request returned status code 412 (Precondition Failed)
{
"error": {
"code": "resourceModified",
"innerError": {
"client-request-id": "1db71ddc-ae37-4563-8e1f-a136d065e35c",
"date": "2023-07-31T06:26:15",
"request-id": "1db71ddc-ae37-4563-8e1f-a136d065e35c"
},
"message": "ETag does not match current item's value"
}
}
Steps to Reproduce
As per above
Thank you.
[ ]: http://aka.ms/onedrive-api-issues [x]: http://aka.ms/onedrive-api-issues
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (5 by maintainers)
@ificator
That certainly reads much better and the examples are much clearer as well