使用Microsoft Graph Python SDK上传文件时遭遇501 (notSupported)错误的求助
Microsoft Graph Python SDK上传文件时遭遇501 (notSupported)错误的求助
我想照着官方文档里的HTTP上传文件示例,用Microsoft Graph Python SDK实现文件上传功能,写了下面这段代码:
async with aiofiles.open(src_file_path, 'rb') as file: file_content = await file.read() dest_folder_name = "FolderA" src_file_name = "FileB.txt" dest_file_path = f"{dest_folder_name}/{src_file_name}" drive_item_id = f"/root:/{dest_file_path}:" uploaded_file = await self.client.drives.by_drive_id(drive_id).items.by_drive_item_id(drive_item_id).content.put(file_content)
结果运行后直接抛出了501错误,具体的错误信息如下:
msgraph.generated.models.o_data_errors.o_data_error.ODataError: APIError Code: 501 message: None error: MainError(additional_data={}, code='notSupported', details=None, inner_error=InnerError(..., message='Cannot upload content to an item representing a folder.', target=None)
我实在搞不明白问题出在哪——明明我指定的路径是FolderA/FileB.txt,是一个文件路径啊,为什么会被识别成文件夹呢?有没有用过这个SDK的朋友能帮我分析下原因,给个解决办法呀?
备注:内容来源于stack exchange,提问作者Luca
相关产品推荐
相关产品推荐

