microsoftgraph / microsoftgraph/msgraph-sdk-python

Error 400 during put on drive item

オープン
#736 コメント 5 件 リアクション 0 件 担当者 1 名 GitHub で見る

@PrzemyslawSagalo がすでに取り組んでいます。

2024年6月3日 から。

Needs: Attention :wave: type:bug
主要言語
Python
スター
630
フォーク
96
平均マージ
15時間 20分
マージ済み PR(30日)
3

説明

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_

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。