Cannot upload file into OneDrive (content type error)
@koros is already working on this.
Since Jul 25, 2023.
Assessment
This issue has not been assessed yet.
Description
Bug Report
Prerequisites
- Can you reproduce the problem?
- Are you running the latest version?
- Are you reporting to the correct repository?
- Did you perform a cursory search?
For more information, see the CONTRIBUTING guide.
Description
Cannot make a PUT request to upload file into OneDrive. The API returns Unable to read JSON request payload error. The docs here say to use text/plain content type, but the library here has it hardcoded to JSON.
Console Errors: [Is there any console error]
{
statusCode: 400,
code: 'BadRequest',
requestId: '6418fb30-de6e-4b41-a53c-7e96eebc348b',
date: 2023-05-12T07:51:14.000Z,
body: '{"code":"BadRequest","message":"Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.","innerError":{"date":"2023-05-12T09:51:14","request-id":"6418fb30-de6e-4b41-a53c-7e96eebc348b","client-request-id":"8142eabc-e22d-a7eb-c8f6-be9ebc37899f"}}',
headers: Headers {
[Symbol(map)]: [Object: null prototype] {
'transfer-encoding': [ 'chunked' ],
'content-type': [ 'application/json' ],
'content-encoding': [ 'gzip' ],
vary: [ 'Accept-Encoding' ],
'strict-transport-security': [ 'max-age=31536000' ],
'request-id': [ '6418fb30-de6e-4b41-a53c-7e96eebc348b' ],
'client-request-id': [ '8142eabc-e22d-a7eb-c8f6-be9ebc37899f' ],
'x-ms-ags-diagnostic': [
'{"ServerInfo":{"DataCenter":"West Europe","Slice":"E","Ring":"5","ScaleUnit":"002","RoleInstance":"AM2PEPF0000BE20"}}'
],
date: [ 'Fri, 12 May 2023 09:51:13 GMT' ],
connection: [ 'close' ]
}
}
}
Screenshots: [If applicable, add screenshots to help explain your problem]
Steps to Reproduce
const filename = 'file.csv';
const content = 'content';
await.client.api(`/drives/${this.driveId}/items/${this.folderId}:/${filename}:/content`).put(content);
Expected behavior: PUT is succesfully sent and file is uploaded
Actual behavior: PUT was sent with invalid content type
Additional Context
Add any other context about the problem here..
Usage Information
check log above
- Dominant language
- TypeScript
- Stars
- 833
- Forks
- 240
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoftgraph/msgraph-sdk-javascript
-
status:waiting-for-triage
Difficulty 1/5 Under an hour Newbie friendliness 62/100
-
Is anyone here? Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
microsoftgraph/msgraph-sdk-javascript#2005 · 1 reaction ·
-
Is it really correct that the Javascript version of the graph SDK doesn't offer typed requests? Openstatus:waiting-for-triage
Difficulty 5/5 Over a week Newbie friendliness 42/100
-
status:waiting-for-triage type:bug
Difficulty 3/5 1-2 days Newbie friendliness 48/100
microsoftgraph/msgraph-sdk-javascript#1999 · 2 comments · 1 reaction ·
-
status:waiting-for-triage type:bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in microsoftgraph/msgraph-sdk-javascript
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100