Skip to main content

Can FME create folders in an on-prem Sharepoint Library? I’m successfully connecting to the library using the Sharepoint List type (Reader and Writer), and looking at written data I can see an existing folder, but I can’t use the writer to create folders.

Safe software have a great article for Getting-Started-with-Microsoft-SharePoint but alas the majority focus’ around using Sharepoint Online, hence the Connector transformer.

Having a quick look at the sharepoint documentation,  appears you might be able to use the same API. d http://server/site/_api/ so you should be able to substitute the first part of the url with your internal address

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom


Would this be using the HTTPCaller transformer? Does this end up looking like 1 workflow step per API call? (one httpCaller to auth and/or get context, separate to loop through with updates?)


I can imagine that would be the case. The sharepointonlineconnector is an fme package with the following actions build into a UI

uploads, downloads, deletes, or lists the contents of files https://hub.safe.com/publishers/safe/packages/microsoft-sharepoint/transformers/SharePointOnlineConnector

underneath all its doing is auth and graph/SharePoint API calls


Do you know of any samples out there that show POST operations from HTTPCaller to Sharepoint? I’ve successfully queried a folder with GET /_api/web/GetFolderByServerRelativeUrl('MyLibraryName'), but this GET request doesn’t require constructing a request body, and doesn’t appear to require any special headers. I’m not having any luck with POST operations (like what headers, what's in the upload?)


its all in this https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest and in general https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service

postman might be a handy tool https://www.postman.com/grey-star-32224/sharepoint-apis/request/hrufx1o/crud-upload-file 

headers - postman

 


What’s missing is how do I plug in 

{length of request body as integer}

within the HTTPCaller header parameters?


you can dive more into the detail of HTTP-Requests-with-the-HTTPCaller where the Header value goes here 

 


I understand where the custom headers go, the issue is how to calculate the request body length in order to populate the value.


Are you sure that that header is required? I myself have never had a need to actually manually use this header in a httpcaller. I don't know if that is because it is not required or if it is something that all calls need and is therefore always added automatically. Can you try the call without this header?


I did test without it, and the request failed so I was trying to eliminate variables.

I determined the problem however. It turns out that for nearly all POST requests to the Sharepoint API, you must supply the custom header X-RequestDigest with a value acquired by sending a POST to /_api/contextinfo.

So my initial test workflow (which is now working) consists of Creator(Transform to start flow) → AttributeFileReader(Transformer to pull in test file) → HTTPCaller(Transformer to get XML containing RequestDigest) → XMLFlattener (Transformer to extract & expose FormDigestValue) → HTTPCaller (Transformer to make actual REST call to Sharepoint).