I've looked all around for a way to make a Document Set in my SharePoint Site Document Library with Power Automate.
I've found many resources to use, but they all use different forms of coding/script. There is JSOM, HTML, HTTP, JSON, REST API, C#, etc... so many different things going on.
Currently the languages I know are PowerShell, Java, and Python. I found some java looking stuff in there, but I still had a hard time getting my head around how to actually do this.
All I want is a simple flow to create a Document Set when a file is created in my SharePoint Document Library. My PowerApp creates these files, and there seems to be no way to make the Document Set in the PowerApp, I am told I need to use PowerAutomate for this.
Can someone help me with this please?
Solved! Go to Solution.
I got it working and I can change the metadata and play with document sets all I want.
There are a few rules I didn't know about in order to make this work.
Here is the HTTP request that worked:
Syntax
Method: POST
Uri:
_vti_bin/listdata.svc/[yourDocumentLibraryName]
If you have spaces or special characters in your Document Library name, you may need to read more here: https://knowhere365.space/microsoft-flow-sharepoint-document-set-creation/
Headers:
Key: Slug
Value:
[siteURL]/[yourDocumentLibrary]/[theNameOfYourNewDocumentSet]|[documentSetContentTypeID]
take a look at the pklumsail connector - it is very cheap and very easy to configure, i use it heaps for document sets and permission management.
I will bring it up with my boss. But I don't know if they want to spend that much money on something they're paying me to figure out... even if it means I need to learn some new programming languages.
I know there is a way to do this task with Power Automate, I just need a little help. I'm sure someone has done this before.
well another option would be to use powershell via azure function, but it will end up costing a lot more than the premium plumsail connectors, not to mention save you a lot of time.
however you can also create it using a SharePoint HTTP call and create it via the REST API.
https://julieturner.net/2016/11/create-sharepoint-document-set-and-set-metadata-using-rest/
We may already have the Azure services. How would I be able to automate the process with PowerShell?
Regarding the other method.... I have an HTTP Request up here and I've read that article regarding the REST API. Where and how do I write code in here?
var webUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.webServerRelativeUrl;
var createDocSet = function(listName, folderName, folderContentTypeId){
var listUrl = webUrl + "/" + listName;
var folderPayload = {
'Title' : folderName,
'Path' : listUrl
};
//Create Folder resource
return $.ajax({
url: webUrl + "/_vti_bin/listdata.svc/" + listName,
method: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(folderPayload),
headers: {
"Accept": "application/json;odata=verbose",
"Slug": listUrl + "/" + folderName + "|" + folderContentTypeId
}
});
};
var webUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.webServerRelativeUrl;
var createDocSet = function(listName, folderName, folderContentTypeId){
var listUrl = webUrl + "/" + listName;
var folderPayload = {
'Title' : folderName,
'Path' : listUrl
};
//Create Folder resource
return $.ajax({
url: webUrl + "/_vti_bin/listdata.svc/" + listName,
method: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(folderPayload),
headers: {
"Accept": "application/json;odata=verbose",
"Slug": listUrl + "/" + folderName + "|" + folderContentTypeId
}
});
};
This is the code from the article. After I adjust it for my needs, would I just slap it into the body of my HTTP Request?
After doing some reading, I'm hoping this is the right Uri and Headers, but I don't know forsure. Its my first time making an HTTP Request.
you will need to re-rewrite it in the correct format in the body section.
here is a proper flow example
https://knowhere365.space/microsoft-flow-sharepoint-document-set-creation/
Thank you! I will read up and try my best to come up with a flow using these resources. When its done, would you mind looking over it with me to make sure it makes sense? 🙂
Heya @Gristy
So I thought I was going to get it working, but its not working right now. I followed the guides and I should be producing the same values in my flow as they are. I don't understand.
Here is what I did for my main HTTP Request:
with variable folderName being exactly what the guides said they should be:
[SiteAddress]/TESTLibrary/TestFolder|0x0120D52000148C3220A60BF742BBE92D3B8545196F00A89AFE183D27EF41A020CA7E33353C91
with TestFolder being the changing variable I use compose for.
It is stuck on the HTTP Request. Look
and the one retry says "BadGateway"
It would be helpful if someone knows the exact code to create a Document Set. I believe I have the required code, but I don't know forsure. It seems like the resources I'm using are slightly outdated, so maybe something was changed, or maybe I'm missing something.
I can't find a good resource to find out what exactly "Slug" does, but I'm assuming that is the command creating the document set?
I got it working and I can change the metadata and play with document sets all I want.
There are a few rules I didn't know about in order to make this work.
Here is the HTTP request that worked:
Syntax
Method: POST
Uri:
_vti_bin/listdata.svc/[yourDocumentLibraryName]
If you have spaces or special characters in your Document Library name, you may need to read more here: https://knowhere365.space/microsoft-flow-sharepoint-document-set-creation/
Headers:
Key: Slug
Value:
[siteURL]/[yourDocumentLibrary]/[theNameOfYourNewDocumentSet]|[documentSetContentTypeID]
I've managed to create a custom content type document set.
Simply replace the document set content type ID with the list document set custom content type ID, which can be obtained as follows.
I'm not convinced about using _vti_bin/listdata.svc, as it is a deprecated legacy Sp2010 api. Is there a similar endpoint for _api?