Has anyone successfully created a REST API to create a folder on SharePoint?

I have been successfully using REST APIs to interact with SharePoint, however I am unable to get the Create Folder functionality working.

Does anyone know what the Method URL should be please?

This what I have so far...

I already saw that thanks but it doesn't help.  The method URL "http://site url/_api/web/folders" doesn't work.


I no longer in that project but I can try to recreate it after sometime when I become little free. Can you post what exactly is the error you are getting when you use folders method?



In this forge component there is an action to create folder https://www.outsystems.com/forge/component-overview/4114/sharepoint-connector, it has URL like /_api/web/folders/add('Shared Documents/FolderA'). Try this and let me know.


Prasad Rao

Thank you, I tried the following 3 method URLs and I've copied the relevant error message under each....

/_api/web/GetFolderByServerRelativeUrl('Shared Documents')/add('Shared Documents/FolderA')
Cannot find resource for the request add

/_api/web/GetFolderByServerRelativeUrl('Shared Documents')/folders/add('Shared Documents/FolderA')
Cannot handle the data at position 0

/_api/web/folders/add('Shared Documents/FolderA')
Cannot handle the data at position 0

...interestingly, the one other REST call I had trouble with was creating a file. In the end I did it in the C# extension I was writing instead.  But both of the (most) troublesome ones I've had involve creating a file/folder.


I was able to create a folder using below in our internal sharepoint site.



Ah that's interesting.  I still get the error 'Cannot handle the data at position 0' when I try that.....hmmm.....

...I'm using SharePoint online.


I also tried in sharepoint online. Did you try going to https://<domain>.sharepoint.com/sites/<SiteName>/Shared%20Documents, did it open in browser?


Yes, that URL opens on my SharePoint site.

FYI, when using Chris' code....(which seems odd as no permissions issues with other RESTs)....


Its really strange that you are getting the error 'Cannot handle the data at position 0',this means it cannot find the resource.

In the above screenshot you are missing the some part of URL after the domain like /sites/<sitename>/


Sorry yes, I made so many changes I omitted it from there when writing that to take a screenshot, but I did include the site details when testing.

I have tried the following and they all generate the same error:  'Cannot handle the data at position 0'.

  1. .../sites/{SiteName}/_api/web/folders/add('Shared Documents/{FolderName}')
  2. .../sites/{SiteName}/_api/web/GetFolderByServerRelativeUrl('Shared Documents')/folders/add('{FolderName}')
  3. .../sites/{SiteName}/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/{FilePath}')/folders/add('{NewFolder}')
  4. .../sites/{SiteName}/_api/web/GetFolderByServerRelativeUrl('{FilePath}')/folders/add('{NewFolder}')

Note that the first one works for another internal SharePoint site but doesn't on the one I need it to.

I think I'll start another post with that error message as the title in case anyone can offer further advice.

Thanks so much for your time and help and help though Prasad, really appreciate it!!


Actually, cancel that - I fixed it!

The problem was that there was some residual code that had been auto generated in the Body Content when playing around and that was affecting it.