Title: Error 501: when uploading a new file · Issue #894 · microsoftgraph/msgraph-sdk-python · GitHub
Open Graph Title: Error 501: when uploading a new file · Issue #894 · microsoftgraph/msgraph-sdk-python
X Title: Error 501: when uploading a new file · Issue #894 · microsoftgraph/msgraph-sdk-python
Description: Describe the bug I'm trying to replicate the HTTP example with the Python SDK as here: 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_...
Open Graph Description: Describe the bug I'm trying to replicate the HTTP example with the Python SDK as here: async with aiofiles.open(src_file_path, 'rb') as file: file_content = await file.read() dest_folder_name = "Fo...
X Description: Describe the bug I'm trying to replicate the HTTP example with the Python SDK as here: async with aiofiles.open(src_file_path, 'rb') as file: file_content = await file.read() dest_folde...
Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-python/issues/894
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error 501: when uploading a new file","articleBody":"### Describe the bug\r\n\r\nI'm trying to replicate the HTTP example with the Python SDK as [here](https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0\u0026tabs=http#example-upload-a-new-file):\r\n```\r\nasync with aiofiles.open(src_file_path, 'rb') as file:\r\n file_content = await file.read()\r\ndest_folder_name = \"FolderA\"\r\nsrc_file_name = \"FileB.txt\"\r\ndest_file_path = f\"{dest_folder_name}/{src_file_name}\"\r\ndrive_item_id = f\"/root:/{dest_file_path}:\"\r\nuploaded_file = await self.client.drives.by_drive_id(drive_id).items.by_drive_item_id(drive_item_id).content.put(file_content)\r\n```\r\n\r\nBut I get a 501 error with message \r\n\r\n\u003e Cannot upload content to an item representing a folder.\r\n\r\n### Expected behavior\r\n\r\nThe file should be uploaded, but I believe there is a problem in the way the `drive_item_id `is built in the `by_drive_item_id `method.\r\n\r\n### How to reproduce\r\n\r\n```\r\ndest_folder_name = \"FolderA\"\r\nsrc_file_name = \"FileB.txt\"\r\ndest_file_path = f\"{dest_folder_name}/{src_file_name}\"\r\ndrive_item_id = f\"/root:/{dest_file_path}:\"\r\n# drive_item_id example: '/root:/FolderA/FileB.txt:'\r\nuploaded_file = await self.client.drives.by_drive_id(drive_id).items.by_drive_item_id(drive_item_id).content.put(file_content)\r\n```\r\n\r\n### SDK Version\r\n\r\n_No response_\r\n\r\n### Latest version known to work for scenario above?\r\n\r\n_No response_\r\n\r\n### Known Workarounds\r\n\r\n_No response_\r\n\r\n### Debug output\r\n\r\n\u003cdetails\u003e\u003csummary\u003eClick to expand log\u003c/summary\u003e\r\n```\r\n\r\nmsgraph.generated.models.o_data_errors.o_data_error.ODataError: \r\n APIError\r\n Code: 501\r\n message: None\r\n error: MainError(additional_data={}, code='notSupported', details=None, inner_error=InnerError(..., message='Cannot upload content to an item representing a folder.', target=None)\r\n\r\n```\r\n\u003c/details\u003e\r\n\r\n\r\n### Configuration\r\n\r\n_No response_\r\n\r\n### Other information\r\n\r\n_No response_","author":{"url":"https://github.com/LuchiLucs","@type":"Person","name":"LuchiLucs"},"datePublished":"2024-09-10T12:14:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/894/msgraph-sdk-python/issues/894"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1a125dd9-2372-392d-4044-23a13d59dd68 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C36A:1069C6:131417C:19A120E:69699D01 |
| html-safe-nonce | 8037a9ff2b73fee4e2adbad9fcebaca75b00929efa724fd71afdac7844d96d63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzZBOjEwNjlDNjoxMzE0MTdDOjE5QTEyMEU6Njk2OTlEMDEiLCJ2aXNpdG9yX2lkIjoiMzU5MjQwNDc1NTE3MTM1MTgwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0aa1dc08e90a3f8134e609b940ddae68ba3e3c50cad859091985dfd9acb24f99 |
| hovercard-subject-tag | issue:2516273220 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-python/894/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d182df72e820f29a0f9d4c2f251ebc762831b1552d007f79f638e46f290759f/microsoftgraph/msgraph-sdk-python/issues/894 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d182df72e820f29a0f9d4c2f251ebc762831b1552d007f79f638e46f290759f/microsoftgraph/msgraph-sdk-python/issues/894 |
| og:image:alt | Describe the bug I'm trying to replicate the HTTP example with the Python SDK as here: async with aiofiles.open(src_file_path, 'rb') as file: file_content = await file.read() dest_folder_name = "Fo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LuchiLucs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoftgraph/msgraph-sdk-python git https://github.com/microsoftgraph/msgraph-sdk-python.git |
| octolytics-dimension-user_id | 17304259 |
| octolytics-dimension-user_login | microsoftgraph |
| octolytics-dimension-repository_id | 534665999 |
| octolytics-dimension-repository_nwo | microsoftgraph/msgraph-sdk-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 534665999 |
| octolytics-dimension-repository_network_root_nwo | microsoftgraph/msgraph-sdk-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width