问题
Hey im trying to use the Microsoft Graph API to upload some files to my Drive.
I am following this link and gave my app the appropriate permissions.
After signing in when i attempt to run the code below:
URL = "https://graph.microsoft.com/v1.0/users/USERNAME/drive"
directory = "directory-on-my-local-machine/"
for i in os.listdir(directory ):
if i.endswith('.docx'):
file_path = os.path.join(directory , i)
file_handle = open(file_path, 'rb')
print('uploading... ', i)
r = requests.put(URL + '/' + i + ":/content", data=file_handle, headers=headers)
print(r.text)
file_handle.close()
i get the following output
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'fileanme.docx'.",
"innerError": {
"request-id": "some-long-as-id",
"date": "2020-05-01T06:07:47"
}
}
}
r.status_code
= 400
Let me know if im doing anything wrong or if you need more information
Thanks
来源:https://stackoverflow.com/questions/61537747/resource-not-found-for-the-segment-filename-when-uploading-file-to-onedrive