"createUploadSession" OneDrive Graph API call failed

QA1 5 Reputation points
2024-10-16T07:01:16.9+00:00

Calling the "createUploadSession" OneDrive Graph API using personal account "A" (created before 11/2019) fails,

but simply changing to account "B" (created recently) succeeds. Account "A" and "B" can use OneDrive on the Web page and they are all personal accounts.

Request 1:

POST /v1.0/me/drive/items/root:/Scan/ttttt.jpg:/createUploadSession HTTP/2
Host: graph.microsoft.com
user-agent: curl/7.81.0
accept: */*
content-type: application/json
authorization: Bearer EwB4A8l6BAAUbDba3x2OMJE......
content-length: 157
{
  "item": {
    "@microsoft.graph.conflictBehavior": "rename",
    "description": "",
    "fileSystemInfo": {
      "@odata.type": "microsoft.graph.fileSystemInfo"
    },
    "name": "ttttt.jpg"
  }
}

If using account "A", the response is as follows:

{
  "error": {
    "code": "invalidRequest",
    "message": "Invalid request",
    "innerError": {
      "date": "2024-09-30T12:52:59",
      "request-id": "9c768b04-0dfd-41d1-a3f0-69c223536fa6",
      "client-request-id": "9c768b04-0dfd-41d1-a3f0-69c223536fa6"
    }
  }
}

If using account "B", the response is as follows:

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession",
  "expirationDateTime": "2024-10-05T13:17:50.988Z",
  "nextExpectedRanges": ["0-"],
  "uploadUrl": "https://api.onedrive.com/rup/1fe3b5cce115f141/eyJSZXNvdXJjZUlEIjoiMUZFM0......"
}

Now just remove "description" from the request.

Request 2:

POST /v1.0/me/drive/items/root:/Scan/ttttt.jpg:/createUploadSession HTTP/2
Host: graph.microsoft.com
user-agent: curl/7.81.0
accept: */*
content-type: application/json
authorization: Bearer EwB4A8l6BAAUbDba3x2OMJE......
content-length: 157
{
  "item": {
    "@microsoft.graph.conflictBehavior": "rename",
    "fileSystemInfo": {
      "@odata.type": "microsoft.graph.fileSystemInfo"
    },
    "name": "ttttt.jpg"
  }
}

If using account "A", the response is as follows:

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession",
  "expirationDateTime": "2024-10-05T13:17:50.988Z",
  "nextExpectedRanges": ["0-"],
  "uploadUrl": "https://api.onedrive.com/rup/1fe3b5cce115f141/eyJSZXNvdXJjZUlEIjoiMUZFM0......"
}

If using account "B", the response is as follows:

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession",
  "expirationDateTime": "2024-10-05T13:17:50.988Z",
  "nextExpectedRanges": ["0-"],
  "uploadUrl": "https://api.onedrive.com/rup/1fe3b5cce115f141/eyJSZXNvdXJjZUlEIjoiMUZFM0......"
}

Why does the "description" in the request cause the request to fail for account "A" but work for account "B".

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,289 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,154 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.