Using REST API, is there a way we can upload a file to SharePoint and also create the folder to which file to be uploaded. Say for example here “/testfolder” does not exist already in SharePoint and we need to create the folder at the time of uploading the file.


Thank you.

1 Answer 1


I don't think this is possible via REST API....Infact it is one of limitation that for doing some simple things you need to make multiple calls in REST API.

To create folder you need to make below call

url: http://site url/_api/web/folders
method: POST
body: { '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': '/document library relative url/folder name'}
    Authorization: "Bearer " + accessToken
    X-RequestDigest: form digest value
    accept: "application/json;odata=verbose"
    content-type: "application/json;odata=verbose"
    content-length:length of post body

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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