Logic apps: Create dummy PDFs with the SharePoint REST API

In one of our projects, we needed a way for users to generate a dummy PDF for a SharePoint document on demand. Not a copy of the original file, but a clearly identifiable placeholder PDF containing demo text such as “This is a dummy PDF”, while still preserving all relevant SharePoint metadata. This approach allowed users to work with a PDF representation without exposing or duplicating the original content.

Security and governance were important requirements. The dummy PDF had to be created using the SharePoint REST API, allowing a Logic App to authenticate via Managed Identity. This avoids client secrets or user credentials and results in a clean, secure, and fully automated setup.

The process is simple. A user sets a SharePoint column like “Create dummy PDF” to Yes, which triggers a Logic App. The Logic App creates the PDF via the REST API and then copies the metadata from the original document to the dummy PDF. In this blog, I’ll explain how this works, how to set values for different SharePoint column types using API calls, how to find the correct __metadata type for a document library and how to find the ServerRelativeUrl.

How to find the metadata type for a SharePoint document library

The metadata type for the SharePoint list is needed to update the properties of the created PDF file.

    • To get the metadata type, we need to find what is called the ListItemEntityTypeFullName of the SharePoint document library.
    • This can be done using the following REST API call.
    • Change the domain, site and document library name and use the API call in a browser.
    https://[domain].sharepoint.com/sites/[site]/_api/web/lists/getbytitle('[Document library name]')?$select=ListItemEntityTypeFullName
    
    https://demo.sharepoint.com/sites/demosite/_api/web/lists/getbytitle('Documenten')?$select=ListItemEntityTypeFullName
    • Look for the ListItemEntityTypeFullName and save the value.
    • In my example the value is: SP.Data.Gedeelde_x0020_documentenItem

    How to find the ServerRelativeUrl

    The server relative URL of the document library is required for the creation of the PDF file. I noticed that this URL is not always the same as the URL you see in the browser. With this API call you can find the correct value.

    • To get the Server Relative URL, we need to find what the ServerRelativeUrl of the SharePoint document library.
    • This can be done using the following REST API call.
    • Change the domain, site and document library name and use the API call in a browser.
    https://[domain].sharepoint.com/sites/[site]/_api/web/lists/getbytitle('[document library name]')?$select=RootFolder/ServerRelativeUrl&$expand=RootFolder
    
    https://demo.sharepoint.com/sites/demosite/_api/web/lists/getbytitle('documenten')?$select=RootFolder/ServerRelativeUrl&$expand=RootFolder
    • Look for the ServerRelativeURL property and save the value.
    • In my example the value is: /sites/demo/Documenten.

    Create a PDF file with SharePoint REST API

    • Add an HTTP action to you logic app.
    • Use the following API call to create a PDF file.
    • Change the domain, site, set the correct Server Relative URL, provide a file name.
    https://[domain].sharepoint.com/sites/[site]/_api/web/GetFolderByServerRelativeUrl('/sites/[site]/[document library]')/Files/add(url='[file name].pdf',overwrite=false)
    • Set the Method to POST.
    • Set a header called Accept to application/json;odata=verbose.
    • Set a header called Content-Type to application/pdf.
    • Set the body with the following code. If needed, change the content value to match your requirements.
    base64ToBinary('JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQogICAvQ29udGVudHMgNCAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNSAwIFIgPj4gPj4gPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0NCA+PgpzdHJlYW0KQlQKL0YxIDI0IFRmCjEwMCA3MDAgVGQKKER1bW15IGRvY3VtZW50LikgVGoKRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmCjAwMDAwMDAwMTAgMDAwMDAgbgowMDAwMDAwMDYwIDAwMDAwIG4KMDAwMDAwMDExNyAwMDAwMCBuCjAwMDAwMDAyNzMgMDAwMDAgbgowMDAwMDAwNDE4IDAwMDAwIG4KdHJhaWxlcgo8PCAvUm9vdCAxIDAgUiAvU2l6ZSA2ID4+CnN0YXJ0eHJlZgo1MzAKJSVFT0Y=')
    • Set the Authentication to Managed identity.
    • Select the correct managed identity.
    • Set the Audience to your SharePoint domain.

    Update the PDFs file properties using the SharePoint REST API

    • Add an HTTP action to you logic app.
    • Use the following API call to update the properties of the PDF file.
    • Change the domain, site, document library name and the correct item ID.
    https://[domain].sharepoint.com/sites/[site]/_api/web/lists/getbytitle('[document library]')/items([item ID])
    
    https://demo.sharepoint.com/sites/demosite/_api/web/lists/getbytitle('Documenten')/items(1)
    • Set the Method to POST.
    • Set a header called Accept to application/json;odata=verbose.
    • Set a header called Content-Type to application/json;odata=verbose.
    • Set a header called X-HTTP-Method to MERGE.
    • Set a header called IF-MATCH to *
    • The basic code for the body is as follows, but you will need to add in your specific SharePoint properties. In the paragraph JSON Examples for property types, you can see the syntax required for different types of SharePoint columns.
    • Set as the type of the __metadata the ListItemEntityTypeFullName of the document library.
    {
      "__metadata": {
        "type": "SP.Data.Gedeelde_x0020_documentenItem"
      },
      "Title": "G.104612",
      "ContentTypeId": "0x010100000AAAAAA111111D9C039461496B7308010097DF96DFF524EA4E900ED55E769ECEAF"
    }
    • Set the Authentication to Managed identity.
    • Select the correct managed identity.
    • Set the Audience to your SharePoint domain.

    JSON Examples for property types

    SharePoint uses different column types to store data. Depending on the column type, different JSON syntax is required. Always use the internal name of the SharePoint column.

    Setting a string: "Title": "This is my string"
    Setting a number: "Number": 1
    Setting a choice field: "ChoiceField": "Choice 1",
    Setting a date field: "Date": "2026-04-20T00:00:00Z"
    Setting a Lookup where multiple values are allowed: "LookupId": { "results": [ 1, 3 ] }
    Setting a Lookup where multiple values are not allowed: "LookupId": 1
    Setting an empty date field: "Date": null
    Setting an empty string: "Title": ""
    Setting an empty number: "Number": null
    Setting a choice field to empty: "CreateDummyPDF": null
    Setting a Lookup where multiple values are allowed to empty: "LookupId": { "results": [] }
    Setting a Lookup where multiple values are not allowed to empty: "LookupId": null

    Note for lookup fields you need the field name plus Id.

    Logic App: Tips and tricks

    Whether you're just getting started with Logic Apps or looking to refine your workflows, this post shares practical tips that can save you time and headaches—especially when working with SharePoint integrations. From handling approval status correctly to formatting JSON for field updates and managing choice fields in conditions, these insights will help you build smarter, more reliable automations. Let’s dive into the details.

    Approve or reject an SharePoint item

    To approve or reject a SharePoint item, use the Set content approval status action. This cannot be done using Create item or Update item actions.

    Using JSON to Update SharePoint Fields

    When creating or updating SharePoint items in Logic Apps, you’ll need to use JSON formatting to set field values correctly.

    {
      "Current Status": {
        "Value": "Closed"
      }
    }

    For a text or date fields:

    {
      "Date": "YourDateValue",
      "Text": "Example"
    }

    For a number field:

    {
      "Number": 1
    }

    Using the Approval Status Field in SharePoint

    To check the approval status of a SharePoint item, refer to the Approval Status field (Dutch: Goedkeuringstatus). This field reflects whether an item is PendingApproved, or Rejected.

    When using this field in Power Automate or other logic-based tools, keep in mind:

    • Always use {ModerationStatus} when referencing this field in condition actions.
    • The display name of the field is Approval Status.
    • The internal name used in conditions or expressions is {ModerationStatus}.
    • Although you might see _ModerationStatus in the URL when filtering or viewing list settings, that version cannot be used directly in expressions or dynamic content.

    Condition check for SharePoint choice field

    When working with choice fields in SharePoint (e.g. Status), you can't directly compare with the field name in a condition. The actual value is nested deeper in the JSON structure. Instead of checking just Status, you need to check Status.Value. This ensures you're comparing the actual selected value of the choice field, not the object that contains it.

    @items('For_each')?['Status']?['Value']

    Adding a Line Break (enter) in an Append to String action

    When working with a For Each loop in Logic Apps, it is often useful to collect output from each iteration. One effective approach is to use the Append to string variable action. In my solution, I needed to build a list where each item appears on a new line. To achieve this, simply add the <br> HTML tag at the end of each appended string to insert a line break.