1

How to configure a custom list form header using SharePoint Rest API?

It can be done using GUI : Configure custom header but I am interested in doing the same using Rest API calls from a flow.

1
  • Let me know if below solution works for you or if you face any issues while using it. Commented Dec 14, 2023 at 14:40

2 Answers 2

0

Yes, you can do it using SharePoint REST API in Power automate flow using "Send HTTP Request to SharePoint" action.

Here are the details required for configuring the list form using JSON (with example data/values):

Method: POST

Request URL:

https://contoso.sharepoint.com/sites/JSONFormatting/_api/web/web/lists/getbytitle('DemoList')/contentTypes('0x010068C1DD7A88F89747A3F7FCACD851E20E')

Here you have to use the content type ID in the list for which you want to apply the JSON formatting.

Body/Payload:

{
    "__metadata": {
        "type": "SP.ContentType"
    },
    "ClientFormCustomFormatter": "{\"headerJSONFormatter\":{\"elmType\":\"div\",\"txtContent\":\"[$Title]\"},\"footerJSONFormatter\":{\"elmType\":\"div\",\"txtContent\":\"[$Description]\"},\"bodyJSONFormatter\":{\"sections\":[{\"displayname\":\"\",\"fields\":[\"Title\",\"Description\"]}]}}"
}

Here:

  • headerJSONFormatter object is associated with the list form "header" layout.

  • [$Title] and [$Description] inside the headerJSONFormatter and footerJSONFormatter object are internal names of column in this format: [$InternalNameOfColumn]. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?

  • Title and Description in bodyJSONFormatter object are display name of columns

You can take above example as reference and convert this as per your requirements in the Power automate flow.

Related thread: SharePoint Online - Removing faulty list form custom body JSON

0
0

Thank you Ganesh for your help, here is how it started to work for me:

  1. GET _api/web/lists/getByTitle('DemoList')/ContentTypes?$filter=Name eq 'Item'

Extract the StringId from above API call response as the Content Type Id which will be used in the next step.

  1. POST _api/web/lists/getByTitle('DemoList')/contentTypes('StringIdFromPreviousStep')

Set these additional headers:

IF-MATCH *

X-HTTP-Method MERGE

Content-Type application/json;odata=verbose

body example:

{"__metadata":{"type":"SP.ContentType"},"ClientFormCustomFormatter":"{\"headerJSONFormatter\":{\"elmType\":\"div\",\"txtContent\":\"test\"}}"}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.