web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Need help making Share...
Power Automate
Unanswered

Need help making Sharepoint Document Set with Power Automate

(1) ShareShare
ReportReport
Posted on by 89

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? 

Categories:
I have the same question (0)
  • Gristy Profile Picture
    2,429 on at

    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.

  • Reylin Profile Picture
    89 on at

    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. 

  • Gristy Profile Picture
    2,429 on at

    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/

  • Reylin Profile Picture
    89 on at

    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.

  • Gristy Profile Picture
    2,429 on at

    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/

  • Reylin Profile Picture
    89 on at

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

  • v-alzhan-msft Profile Picture
    on at

    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.

  • Reylin Profile Picture
    89 on at

    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

  • Reylin Profile Picture
    89 on at

    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? 

  • Verified answer
    Reylin Profile Picture
    89 on at

    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]

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard