-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Hi,
When trying to use the createFolder function in teh wrapper for a sharepoint on-premise site. I saw that the function as it stands was causing a 400 error to come back saying bad format or something along those lines.
I did some research and found on the microsoft site (https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest) how a create folder example should work. I compared this to the PLGSharepointOnPremisesClient class and noticed 2 changes that needed to happen.
1st. instead of
RequestEntity<String> requestEntity = new RequestEntity<>(payloadStr, headers, HttpMethod.POST, this.tokenHelper.getSharepointSiteUrl("/_api/web/GetFolderByServerRelativeUrl('" + baseFolderRemoteRelativeUrl + "')/folders"));
we need it to be
RequestEntity<String> requestEntity = new RequestEntity<>(payloadStr, headers, HttpMethod.POST, this.tokenHelper.getSharepointSiteUrl("/_api/web/folders") );
The 2nd change could be done either in the class or in the calling function.
But i noticed the payload object itself was also causing issues it looks like and when i passed a null payload to the createFolder function the logic you have in place properly generates a new payload. So either updating createFodler to not take in a payload or updating your readme example to pass a null payload should work.
After doing that i was able to get a folder created on my sharepoint site.
Hope this helps