Create Site Script for Organisation List Template
How to create a site script which can be used in an Organisation List template in a SharePoint Online tenant using a Power Automate flow.
URI
_api/Microsoft.SharePoint.Utilities.WebTemplateExtensions.SiteScriptUtility.CreateSiteScript(Title='Custom Site Script for List Template') |
Headers
{ | |
"Accept": "application/json;odata=verbose", | |
"Content-Type": "application/json;odata=verbose" | |
} |
Body
{ | |
"$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json", | |
"actions": [ | |
{ | |
"verb": "createSPList", | |
"listName": "HelloWorld", | |
"templateType": 100, | |
"subactions": [ | |
{ | |
"verb": "setDescription", | |
"description": "Hello World Example" | |
}, | |
{ | |
"verb": "addSPView", | |
"name": "All Items", | |
"viewFields": [ | |
"LinkTitle", | |
"ID" | |
], | |
"query": "", | |
"rowLimit": 30, | |
"isPaged": true, | |
"makeDefault": true, | |
"formatterJSON": "", | |
"replaceViewFields": true | |
} | |
] | |
} | |
], | |
"bindata": { }, | |
"version": 1 | |
} |
Screenshot with example
Sample data
Site Address – https://contoso-admin.sharepoint.com (SharePoint Online Admin Centre URL)
Title – Custom Site Script for List Template
Site Script actions used: createSPList & addSPView
Copy/paste example
{"id":"311f481d-8b7b-426a-80bf-7d4a278ae045","brandColor":"#036C70","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/exp_sharedsharepointonline_e5efa"}}},"connectorDisplayName":"SharePoint","icon":"https://connectoricons-prod.azureedge.net/releases/v1.0.1664/1.0.1664.3477/sharepointonline/icon.png","isTrigger":false,"operationName":"Send_an_HTTP_request_to_SharePoint","operationDefinition":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"HttpRequest","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"@parameters('SPO_AdminCentre_Url (ubs_SPO_AdminCentre_Url)')","parameters/method":"POST","parameters/uri":"_api/Microsoft.SharePoint.Utilities.WebTemplateExtensions.SiteScriptUtility.CreateSiteScript(Title='Custom Site Script for List Template')","parameters/headers":{"Accept":"application/json;odata=verbose","Content-Type":"application/json;odata=verbose"},"parameters/body":"{\n\"$schema\": \"https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json\",\n\"actions\": [\n{\n \"verb\": \"createSPList\",\n \"listName\": \"HelloWorld\",\n \"templateType\": 100,\n \"subactions\": [\n {\n \"verb\": \"setDescription\",\n \"description\": \"Hello World Example\"\n },\n {\n \"verb\": \"addSPView\",\n \"name\": \"All Items\",\n \"viewFields\": [\n \"LinkTitle\",\n \"ID\"\n ],\n \"query\": \"\",\n \"rowLimit\": 30,\n \"isPaged\": true,\n \"makeDefault\": true,\n \"formatterJSON\": \"\",\n \"replaceViewFields\": true\n }\n ]\n}\n],\n\"bindata\": { },\n\"version\": 1\n}"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{},"metadata":{"operationMetadataId":"a352b36e-bdad-4aa1-9154-f09286722f90"}}} |
Resources
Site design and site script REST API
That’s it, Happy testing!