microsoftgraph / microsoftgraph/msgraph-sdk-python

Error 400 during put on drive item

Aperta
#736 5 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@PrzemyslawSagalo ci sta già lavorando.

Dal 3/6/2024.

Needs: Attention :wave: type:bug
Lingua principale
Python
Stelle
630
Fork
96
Merge medio
15h 20m
PR unite (30g)
3

Descrizione

Describe the bug

I am trying to upload a .docx file into OneDrive using Graph API. Unfortunately, it returns an error 400.

msgraph.generated.models.o_data_errors.o_data_error.ODataError:
{
APIError
Code: 400
error: MainError(code='BadRequest', message='Entity only allows writes with JSON Content-Type header.')
}
Expected behavior

Based on the type from the code of the sdk passed type is correct, so I don't understand this behaviour and the bellow code should upload the file.

How to reproduce
file_path = "test.docx"
with open(file_path, "rb") as file_handle:
    file_bytes = file_handle.read()

item_path = "/root:/Documents/test_on_one_drive.docx"
r = await client.drives.by_drive_id(drive_id).items.by_drive_item_id(item_path).content.put(body=file_bytes)
SDK Version

1.4.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

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.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.