Provisioning SiteScript generation changes causing errors in execution.

Copper Contributor

On Tuesday evening 4/25 after 6pm CST I noticed an error with power automate running the SharePoint HTTP control to call the API
_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.ExecuteTemplateScript()
of 
Action 1 (createSPList) is invalid. Parameter addNavLink has an invalid value.

 

This was due to a change in the JSON generated by the SharePoint HTTP control calling the API

_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.GetSiteScriptFromList()

 

It appears that something has changed.  The snippet below of the top of the json worked minutes before.

    "actions": [
      {
        "verb": "createSPList",
        "listName": "DCNfiles",
        "templateType": 101,
        "subactions": [

 

But changed to the snippet below that began producing the error.

    "actions": [
      {
        "verb": "createSPList",
        "listName": "[[LDCNfiles0001_listName]]",
        "templateType": 101,
        "color": "[[LDCNfiles0001_color]]",
        "icon": "[[LDCNfiles0001_icon]]",
        "addNavLink": "[[LDCNfiles0001_addNavLink]]",
        "description": "[[LDCNfiles0001_description]]",
        "identity": "LDCNfiles0001",
        "subactions": [
 
  And at the bottom of the JSON new bindings were added.
"bindings": {
      "LDCNfiles0001_listName": {
        "source": "Input",
        "defaultValue": "DCNfiles"
      },
      "LDCNfiles0001_icon": {
        "source": "Input",
        "defaultValue": "0"
      },
      "LDCNfiles0001_description": {
        "source": "Input",
        "defaultValue": ""
      },
      "LDCNfiles0001_color": {
        "source": "Input",
        "defaultValue": "0"
      },
      "LDCNfiles0001_addNavLink": {
        "source": "Input",
        "defaultValue": "false"
      }
    }
 
I isolated the single control and tried it on 4 other tenants, and they all showed the same result.  There wasn't anything unusual about the library being copied and I've gotten the same issue with newly created lists.  I also attempted testing this with PowerShell with the commands Get-SPOSiteScriptFromWeb and Get-SPOSiteScriptFromList getting the same results.
 
 
Has anyone seen this or know a way to fix the issue?
9 Replies
I am experiencing the same issue and I need to urgently resolve this. Appreciate any help.
I am also experiencing the same issue
I have the same issue as of April 25th. My last successful run was April 24th around 4:30pm. Nothing on my end has changed.

My error on step "Send_an_ HTTP_request_to_Sharepoint_-_ExecuteTemplateScript":
Action 'Send_an_HTTP_request_to_SharePoint_-_ExecuteTemplateScript' failed
Error Details are:
Action 1 (createSPList) is invalid. Parameter addNavLink has an invalid value.

When researching the output of the successful "Send_an_HTTP_request_to_SharePoint_-_get_list_structure" step, of the flow that had completed successfully, I find this:
\"actions\": [\r\n {\r\n \"verb\": \"createSPList\",\r\n \"listName\": \"Onboarding Team Tasks Template_LST\",
And when I research the flow that ran the next day, I find this:
\"actions\": [\r\n {\r\n \"verb\": \"createSPList\",\r\n \"listName\": \"[[LOnboarding_Team_Task0001_listName]]\",

Again, nothing on my end changed. Something in Microsoft world must have changed.
Thank you!
I was able to get everything working again by including the new bindings property that was added when generating the JSON. There also doesn't appear to be an issue with including the $schema property so the entire generated JSON can be used now.

Do you have any more detailed instructions on how you resolved this? Trying to resolve this for a client and it's time sensitive.

 

EDIT: Thanks to your hint pointing me in the right direction, I figured it out. For anyone who finds this topic later:

 

Instead of a request body like this:

 

{"script": "{\"actions\":@{replace(replace(string(variables('GetSiteScriptFromList')?['actions']),'\','\\'),'"','\"')}}"}

 

It should now look like this:

 

{"script": "@{replace(replace(string(variables('GetSiteScriptFromList')),'\','\\'),'"','\"')}"}

 

Note that the entire getSiteScriptFromList object can now be referenced between the quotes in the script property, instead of referencing a specific property, and the {} are no longer needed as they are included in the object:

{"script": "YourFormattedGetSiteScriptFromListStringHere"}

I had a similar issue with my flow.  It worked fine without the bindings in the body of my REST call until last Friday, but thanks to @DeanOfReply's and @Stephen600's examples I was able to figure it out.  If you're using the setProperty function to rename your new list, the body should look something like this in order to add the bindings:

 

{"script": "{\"actions\": [@{replace(replace(string(setProperty(body('Parse_JSON')?['actions'][0],'listName', variables('BackupTitle'))),'\','\\'),'"','\"')}], \"bindings\": @{replace(replace(string(body('Parse_JSON')?['bindings']),'\','\\'),'"','\"')}}"}

 

In my case, I'm using the output of a Parse JSON step instead of a variable to store the list structure.  If you're renaming the list in a variable, you may need to use addProperty to add bindings back into your JSON since setProperty will only return the actions part when you use it to set the new name.

Thanks all for the comments on this. Very helpful.

For those that have followed the blog step by step, I updated the final HTTP request body to the following:
{"script": "@{replace(replace(string(body('Parse_JSON')),'\','\\'),'"','\"')}"}

And saw sweet success.

@AdamKB-Artelia 

thanks but when i try to change the name of the new list i dont get it worked 

 

https://tomriha.com/change-the-name-of-sharepoint-list-from-template-with-power-automate/

 

replace(replace(string(setProperty(body('Parse_JSON')?['actions'][0],'listName', 'New list name')),'\','\\'),'"','\"')

 

working at yours ? 

 

Thanks

Hey, I have just written this blog post, where I describe how to provision a list using site script, and there you can also find steps about manipulation of the site script JSON to e.g. change list's title or switch the flag to add it to site navigation: https://poszytek.eu/en/microsoft-en/office-365-en/powerautomate-en/provisioning-sharepoint-online-li.... Hope it helps! :)