Power Automate: Creating and updating a document set in SharePoint

Many colleagues have asked me how to create or update document sets with Power Automate. I had never done this before so I told them to use a web service. From now on, I can point them to this blog post. The flow is created with the help of my colleague Jasper Voskuilen, because this web service is a bit more complicated to setup.

Creating the flow

  • Open Power Automate and create a new flow (automation).
  • I created a flow with the trigger, for a selected item.
  • In my situation I get all items from a list and then create a document set for each result.
  • Create the following variables with the related values.
  • This will make the flow more dynamic for later changes.
  • SiteURL as a string, fill in the Site URL.
  • ContentType as a string, fill in the content type id.
  • URLLibrary as a string, fill in the library name part of the ULR.
    For this example it is: Library
https://domein.sharepoint.com/sites/ExampleSite/Library/Forms/allitems.aspx
  • TitleLibrary as a string, fill in the title (name) of the library.
  • WebServiceURLBibliotheek as a string, fill in the Library URL used by the web service.
  • You can find the web service url by using the following URL
https://domein.sharepoint.com/sites/ExampleSite/_vti_bin/listdata.svc/
  • Add the action Send an HTTP request to SharePoint
  • Use the varibles to configure the web service.
  • The name of the document set needs to be unique. I used a value from my list item, your situation might be different.
  • If required you can update the newly created document set.
  • Add the action Parse JSON and parse the Body of the Create Document set HTTP request.
  • Add the action Send an HTTP request to SharePoint
  • Use the variables to configure the web service.
  • The properties you need to set might be different than mine. I used values from my list item but your situation might be different.
Share

11 Replies to “Power Automate: Creating and updating a document set in SharePoint”

  1. Hi Ben, Could you please show what this would look like if we need to update document sets that have already been created? I’m trying to migrate and update some historical document sets and I’m not sure which variables I need

  2. Ben,

    I’m hoping someone might have a suggestion for me. My power automate flow makes document sets successfully following the approaches mentioned above. However one thing is not working. I have turned on document IDs and if I make a document set in the library itself it creates the document ID just fine. But a document set created from the flow does not create a document ID. Can anyone suggest where I might look to solve this problem?

  3. Hey Ben,

    Thanks for compiling this guide, it’s the first one that’s worked!

    I can create a document set but when trying to update the managed metadata columns I’m getting this erro:

    The type SP.ListItemEntityCollection does not support HTTP PATCH method.

    Have you come across this before?

    I’ve tried with two users who are Site Admins and managers of the Term Store. Any insights would be appreciated.

    Cheers,

    Jeff

    1. Hi Jeff,

      Thank you for your kind words.
      My first thought about that error is that you might be using an incorrect URL.
      Are you using a relative URL or absolute? You should be using an relative URL in the URI part.
      I have never encounter this error myself so I am not sure.

      1. Hey Ben,

        I realised that the JSON parse wasn’t passing the ID of the newly created Document Set. Deleting the Parse JSON step and recreating it got past that hurdle.

        Now I have another issue. I’m trying to update metadata columns and I’m getting an error: An unexpected ‘PrimitiveValue’ node was found when reading from the JSON reader. A ‘StartObject’ node was expected.

        The output is:

        {
        “statusCode”: 400,
        “headers”: {
        “Pragma”: “no-cache”,
        “x-ms-request-id”: “e415b89f-508e-b000-f1b5-c0a8f848eef2”,
        “Strict-Transport-Security”: “max-age=31536000; includeSubDomains”,
        “X-Content-Type-Options”: “nosniff”,
        “X-Frame-Options”: “DENY”,
        “Cache-Control”: “no-store, no-cache”,
        “Set-Cookie”: “ARRAffinity=9c9c847b5bd6c73a56d4f1afae4aecaa7f5b746d703be6c728afc87b6c50d7e3;Path=/;HttpOnly;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net,ARRAffinitySameSite=9c9c847b5bd6c73a56d4f1afae4aecaa7f5b746d703be6c728afc87b6c50d7e3;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net”,
        “Timing-Allow-Origin”: “*”,
        “x-ms-apihub-cached-response”: “true”,
        “Date”: “Fri, 26 Mar 2021 15:40:14 GMT”,
        “Content-Length”: “493”,
        “Content-Type”: “application/json”,
        “Expires”: “-1”
        },
        “body”: {
        “status”: 400,
        “message”: “An unexpected ‘PrimitiveValue’ node was found when reading from the JSON reader. A ‘StartObject’ node was expected.\r\nclientRequestId: 31fac4d3-aa2a-41f2-97af-f9f7ac2fede6\r\nserviceRequestId: e415b89f-508e-b000-f1b5-c0a8f848eef2”,
        “source”: “https:///_api/web/lists/GetByTitle(‘Cases%20002’)/items(76)”,
        “errors”: [
        “-1”,
        “Microsoft.SharePoint.Client.InvalidClientQueryException”
        ]
        }
        }

        The body is:

        {
        “__metadata”: { “type”: “SP.Data.Cases_x0020_002Item” },
        “DMS_x0020_IRN”: “#M107986”,
        “Inprotech_x0020_IRN”: “#M107986”,
        “DocumentSetDescription”: “docsetdescription”
        }

        Any ideas would be appreciated 🙂

        Cheers,

        Jeff

  4. That might be an issue with a choice field, are you using that?
    Try to set an default value for the choice field or remove it if you have one.

  5. Hi Ben
    Have you ever needed to create recurring reminder flows on document sets, based on review dates on documents within the set? I have a large number of document sets, each with a different document owner and each document within each set has different review dates. I have started playing around with simple reminder flows, but haven’t tried it out on any document sets yet.
    Thanks

  6. Hi Jan,

    I have not, but seems like a nice flow to build.
    It looks posisble with flow based on your description.

Leave a Reply to Ben Prins Cancel reply

Your email address will not be published. Required fields are marked *