1

I'm using the official Office365-REST-Python-Client which basically is a wrapper to submit HTTP requests. I'm looking at the documentation and have been succesfully able to upload documents to the site, however they are all going straight to the Shared Documents Folder. When I try specifying a subfolder, I get a HTTP 404 client error because the API is creating a bad request.

HTTPError: 404 Client Error: Not Found for url: https://domain.sharepoint.com/sites/site_name/_api/Web/lists/GetByTitle('Documents%2Ftest%2F')/RootFolder/Files/add(overwrite=true,url='runtime_table.csv')

I've been reading the documentation and understand I need to add a subfolder to the REST query, but I'm not sure how to do that within the Python library? Any help would be greatly appreciated, thanks.

2

I suggest to use this endpoint:

http://<site url>/_api/web/GetFolderByServerRelativeUrl('<folder relative url>')/files/add(overwrite=true, url='runtime_table.csv')
|improve this answer|||||
0

This is the endpoint to do that:

/sites/Developer/_api/web/lists/getByTitle('MyDoc4')/RootFolder/folders('SubFolder')/files/add(url='test.txt',overwrite=true)

Using postman tool quickly you can test this POST upload function before going into the coding implementation.

Similar question is answered here:

Add files to subfolders using rest api in javascript

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.