Describe the bug
I am trying to upload a PDF file to OneDrive, but I receive a 400 APIError with an Invalid Request.
Expected behavior
Successful upload of the file.
How to reproduce
files= [item.nameforiteminawaitself._get_onedrive_items(
query_filter="file ne null and file/mimeType eq 'application/pdf'"
)]
folder_id_map=awaitself._get_folder_ids(source_folders)
forfolderinsource_folders:
folder_path=os.path.join('documents', folder)
ifnotos.path.exists(folder_path):
continueforfile_nameinos.listdir(folder_path):
iffile_nameinfiles:
continuefile_path=os.path.join(folder_path, file_name)
withopen(file_path, 'rb') asfile:
file_content=file.read()
folder_id=folder_id_map.get(folder)
ifnotfolder_id:
print(f"Folder ID for '{folder}' not found.")
continueparent_reference=ItemReference(
id=folder_id
)
drive_item=DriveItem(
name=file_name,
file=File(),
parent_reference=parent_reference,
content=file_content
)
try:
response=awaitself._user_client.drives.by_drive_id(
os.getenv('ONEDRIVE_DEV_DRIVE_ID')
).items.post(drive_item)
print("Response", response)
exceptExceptionase:
print(f"Failed to upload file '{file_name}': {e}")SDK Version
msgraph-core~=1.1.2 msgraph-sdk~=1.5.3
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```
APIError
Code: 400
message: None
error: MainError(additional_data={}, code='invalidRequest', details=None, inner_error=InnerError(additional_data={}, client_request_id='13230f64-2c2e-4083-93c1-f7325291333c', date=DateTime(2024, 8, 22, 10, 12, 34, tzinfo=Timezone('UTC')), odata_type=None, request_id='f1815677-f808-46dd-af6d-7882803e975b'), message='Invalid request', target=None)
</details>
### Configuration
- OS: Windows
- architecture: AMD64
### Other information
The 400 APIError could be more robust than just "Invalid request"
Describe the bug
I am trying to upload a PDF file to OneDrive, but I receive a 400 APIError with an Invalid Request.
Expected behavior
Successful upload of the file.
How to reproduce
SDK Version
msgraph-core~=1.1.2 msgraph-sdk~=1.5.3
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```APIError
Code: 400
message: None
error: MainError(additional_data={}, code='invalidRequest', details=None, inner_error=InnerError(additional_data={}, client_request_id='13230f64-2c2e-4083-93c1-f7325291333c', date=DateTime(2024, 8, 22, 10, 12, 34, tzinfo=Timezone('UTC')), odata_type=None, request_id='f1815677-f808-46dd-af6d-7882803e975b'), message='Invalid request', target=None)