cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Need help making Sharepoint Document Set with Power Automate

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate I
Advocate I

Re: Need help making Sharepoint Document Set with Power Automate

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. 

 

  1. You can only create the default Document Sets with Power Automate. You cannot create custom Document Sets, you cannot create custom Content types. 
  2. You must get the Content Type ID for the default Document Set from the Library Settings > Content Types: Document Set.
    the ID is located on the page "List Content Type", in the URL after ctype=
  3. There must NOT be a folder or document set with the same name as the Document Set you're creating with the Flow. 

Here is the HTTP request that worked: 
Annotation 2020-01-24 104524.png

 

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]

 

View solution in original post

10 REPLIES 10
Highlighted
Super User
Super User

Re: Need help making Sharepoint Document Set with Power Automate

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.

Highlighted
Advocate I
Advocate I

Re: Need help making Sharepoint Document Set with Power Automate

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. 

Highlighted
Super User
Super User

Re: Need help making Sharepoint Document Set with Power Automate

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/

Highlighted
Advocate I
Advocate I

Re: Need help making Sharepoint Document Set with Power Automate

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?
Annotation 2020-01-20 161458.png

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.

Highlighted
Super User
Super User

Re: Need help making Sharepoint Document Set with Power Automate

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/

Highlighted
Advocate I
Advocate I

Re: Need help making Sharepoint Document Set with Power Automate

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? 🙂 

Highlighted
Community Support
Community Support

Re: Need help making Sharepoint Document Set with Power Automate

Hi @Reylin ,

 

Please take a try with @Gristy 's suggestion.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Advocate I
Advocate I

Re: Need help making Sharepoint Document Set with Power Automate

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: 
Annotation 2020-01-21 165607.png

 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
Annotation 2020-01-21 165902.png

and the one retry says "BadGateway"
Annotation 2020-01-21 170000.png

Highlighted
Advocate I
Advocate I

Re: Need help making Sharepoint Document Set with Power Automate

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? 

Highlighted
Advocate I
Advocate I

Re: Need help making Sharepoint Document Set with Power Automate

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. 

 

  1. You can only create the default Document Sets with Power Automate. You cannot create custom Document Sets, you cannot create custom Content types. 
  2. You must get the Content Type ID for the default Document Set from the Library Settings > Content Types: Document Set.
    the ID is located on the page "List Content Type", in the URL after ctype=
  3. There must NOT be a folder or document set with the same name as the Document Set you're creating with the Flow. 

Here is the HTTP request that worked: 
Annotation 2020-01-24 104524.png

 

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]

 

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (12,264)