microsoftgraph / microsoftgraph/msgraph-sdk-python

Setting additional_data for DriveItemUploadableProperties throw 400

未關閉
#949 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

area:uploads type:bug
主要語言
Python
星號
630
分支
96
平均合併
15 小時 20 分鐘
30 天內合併 PR
3

描述

Describe the bug

When try to add any field from the docs, such as "description" or "@microsoft.graph.conflictBehavior" to DriveItemUploadableProperties from msgraph.generated.models.drive_item_uploadable_properties msgraph throw this:

E           msgraph.generated.models.o_data_errors.o_data_error.ODataError: 
E                   APIError
E                   Code: 400
E                   message: None
E                   error: MainError(additional_data={}, code='invalidRequest', details=None, inner_error=InnerError(additional_data={}, client_request_id='463c4945-0f9c-435e-9ece-30e48ff358b6', date=DateTime(2024, 11, 6, 8, 37, 41, tzinfo=Timezone('UTC')), odata_type=None, request_id='48083d5b-ecd3-4176-8447-112ab2233e72'), message='The request is malformed or incorrect.', target=None)

code i used for this:

        sp_url = f'{self.drive_path}/items/root:{remote_path}:'
        sp_session_url = sp_url + '/createUploadSession'

        base_request_builder = (
            self.client.drives.by_drive_id(self.drive_id)
            .items.by_drive_item_id("root").create_upload_session.with_url(
                sp_session_url,
            )
        )
        create_session_response = await base_request_builder.post(
            CreateUploadSessionPostRequestBody(
                item=DriveItemUploadableProperties(
                    name=file_name,
                    additional_data={
                        "@microsoft.graph.conflictBehavior": "rename",
                    },
                ),
            )
        )

I also tried to add additional_data to CreateUploadSessionPostRequestBody but it does nothing

Expected behavior

When uploading file to Sharepoint and file with the same name already exists it must add suffix (1) or _1 to the new file

How to reproduce

try to upload file with createUploadSession if file with that name already exists using code above

SDK Version

1.9.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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 create_upload_session 進入點開始,檢查 DriveItemUploadableProperties 和 CreateUploadSessionPostRequestBody 如何將額外資料序列化至 additional_data。使用 msgraph.generated.models.drive_item_uploadable_properties 和 @microsoft.graph.conflictBehavior 欄位重現 issue 中的要求。當 createUploadSession 接受文件中說明的欄位,並在檔案已存在時套用要求的衝突行為,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
api
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。