OneDrive / onedrive-api-docs

Official documentation for the OneDrive API
MIT License
447 stars 228 forks source link

createUploadSession fails when fileSystemInfo supplied #1756

Open ReviveDigitalTeam opened 7 months ago

ReviveDigitalTeam commented 7 months ago

The documented properties for createUploadSession include: fileSystemInfo Per: https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online#properties

I would like to supply a lastModifiedDateTime.

If the fileSystemInfo object is supplied at all, with any properties, the request fails. These are the available properties of fileSystemInfo:

{
  "createdDateTime" : "datetime",
  "lastAccessedDateTime": "datetime",
  "lastModifiedDateTime" : "datetime"
}

Example successful request:

{
    "item": {
        "@microsoft.graph.conflictBehavior": "replace"
    }
}

Example failing request:

{
    "item": {
        "fileSystemInfo": {
            "lastModifiedDateTime": "2023-11-16T01:06:28.7971778+00:00"
        },
        "@microsoft.graph.conflictBehavior": "replace"
    }
}

ID's from Graph Explorer: "client-request-id": "2b69e814-af57-232a-8793-32234145768a", "request-id": "9b3f0a6d-0970-4fa1-9991-e184d3724785"

Please could you fix graphAPI so that it matches the documentation (not the other way around)?

potoo0 commented 2 months ago

It works for me,

example (idea http):

### create session with meta
POST https://graph.microsoft.com/v1.0/me/drive/root:/test-modtime/test-file-session:/createUploadSession
Authorization: {{token}}
Content-Type: application/json

{
  "item": {
    "@microsoft.graph.conflictBehavior": "replace",
    "fileSystemInfo": {
      "createdDateTime": "2024-04-24T02:28:27.433Z",
      "lastModifiedDateTime": "2024-04-25T02:28:27.433Z"
    }
  }
}

<> 2024-04-26T140903.200.json

### upload
PUT https://api.onedrive.com/rup/6349fe61df03d513/eyJSZX
Content-Length: 96
Content-Range: bytes 0-95/96

< main.go

<> 2024-04-26T141705.201.json
#{
# ...
#  "createdDateTime": "2024-04-26T06:17:04.35Z",
#  "lastModifiedDateTime": "2024-04-26T06:17:04.35Z",
#  "name": "test-file-session",
#  "size": 96,
#  "fileSystemInfo": {
#    "createdDateTime": "2024-04-24T02:28:27.433Z",
#    "lastModifiedDateTime": "2024-04-25T02:28:27.433Z"
#  },
#  "lenses": []
#}