2

What is working right now is i can upload to the root folder of a library using the code below :

 myDropzone.options.url = `${_context.pageContext.web.absoluteUrl}/_api/web/Lists/getById('${_parent.props.listName}')/rootfolder/files/add(overwrite=true,url='${file.name}')`;   

What i want is to be able to send the files to a specific folder. i have tried using the below code but i get 404 error.

 myDropzone.options.url = `${_context.pageContext.web.absoluteUrl}/_api/web/Lists/getById('${_parent.props.listName}')/folders/folder1/files/add(overwrite=true,url='${file.name}')`;   




myDropzone.options.url = `${_context.pageContext.web.absoluteUrl}/_api/web/Lists/getById('${_parent.props.listName}')/rootfolder/folders/folder1/files/add(overwrite=true,url='${file.name}')`;   
3

I tested below endpoint in fiddler, it works fine.

Correct your endpoint as folders('folder1').

/sites/Developer/_api/web/lists/getByTitle('MyDoc4')/RootFolder/folders('SubFolder')/files/add(url='test.txt',overwrite=true)
  • am still getting the error 400 ${_context.pageContext.web.absoluteUrl}/_api/web/Lists/getById('${_parent.props.listName}')/rootfolder/folders('folder1')files/add(overwrite=true,url='${file.name}'); – Keshav Taurah Dec 13 '18 at 7:59
  • i missed a '/' before files. it works – Keshav Taurah Dec 13 '18 at 8:03
  • but if i have something like this folders('folder1/folder2'), it doesn't work – Keshav Taurah Dec 13 '18 at 8:06
  • 1
    Use /_api/web/lists/getByTitle('MyDoc4')/RootFolder/folders('SubFolder')/folders('F')/files/add() – Lee_MSFT Dec 13 '18 at 8:42
  • i am getting the path dynamically,is there any other solution where i can just inject "folder1/subfolder2/subfolder3/..." . The code above is a static way if you know the exact subfolder numbers – Keshav Taurah Dec 13 '18 at 10:19

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.