Cannot upload file into OneDrive (content type error)

Aperta
#1,276 6 commenti 1 reazione 1 assegnatario Vedi su GitHub

@koros ci sta già lavorando.

Dal 25/7/2023.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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

Lingua principale
TypeScript
Stelle
833
Fork
240
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoftgraph/msgraph-sdk-javascript

Tutte le issue di microsoftgraph/msgraph-sdk-javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.