0

We are using /pages beta endpoint to create modern page and then add few web parts.

We are successful in adding List and Text web part. However when we are adding quick links web part, we see below error

enter image description here

I understand there is some issue with Request body payload. This payload is copied from existing quick links web part through workbench trick. Below is the payload.

Would you know what is wrong with the format?

All the examples I have referred are trying through PowerShell or C# and forming JSON explicitly.

{
"name": "LinPage.aspx",
"title": "EriDefault",
"publishingState": {
    "level": "checkout",
    "versionId": "0.1"
},
"webParts": [
    {
        "type": "c70391ea-0b10-4ee9-b2b4-006d3fcad0cd",
        "data": {
            "title": "Quick links",
            "description": "Show a collection of links in a variety of layouts with options for icons, images, and audience targeting.",
            "dataVersion": "2.2",
            "audiences": [],
            "serverProcessedContent": {
                "htmlStrings": {},
                "searchablePlainTexts": {
                    "items[0]/title": "Testevent"
                },
                "imageSources": {},
                "links": {
                    "baseUrl": "/sites/eri",
                    "items[0]/sourceItem/url": "/sites/eri/SitePages/Testevent.aspx"
                },
                "componentDependencies": {
                    "layoutComponentId": "706e33c8-af37-4e7b-9d22-6e5694d92a6f"
                }
            },
            "properties": {
                "isMigrated": true,
                "layoutId": "CompactCard",
                "shouldShowThumbnail": true,
                "imageWidth": 100,
                "hideWebPartWhenEmpty": true,
                "dataProviderId": "QuickLinks",
                "webId": "41bf8ea8-3d19-4364-af8e-d3aa78602289",
                "siteId": "211cf7bf-caf4-4ecd-91b0-c30174aa2e07",
                "items": [
                    {
                        "sourceItem": {
                            "guids": {
                                "siteId": "211cf7bf-caf4-4ecd-91b0-c30174aa2e07",
                                "webId": "41bf8ea8-3d19-4364-af8e-d3aa78602289",
                                "listId": "2f5879de-62d3-40e8-b946-4c6ae3ec0d18",
                                "uniqueId": "5846afa2-fb3b-4a0c-9f9d-d04b0e21a3cd"
                            },
                            "itemType": 0,
                            "fileExtension": ".ASPX",
                            "progId": null
                        },
                        "thumbnailType": 3,
                        "id": 1,
                        "description": "",
                        "altText": "",
                        "rawPreviewImageMinCanvasWidth": 32767
                    }
                ],
                "buttonLayoutOptions": {
                    "showDescription": false,
                    "buttonTreatment": 2,
                    "iconPositionType": 2,
                    "textAlignmentVertical": 2,
                    "textAlignmentHorizontal": 2,
                    "linesOfText": 2
                },
                "listLayoutOptions": {
                    "showDescription": false,
                    "showIcon": true
                },
                "waffleLayoutOptions": {
                    "iconSize": 1,
                    "onlyShowThumbnail": false
                }
            }
        }
    }
]}

What is the right forrmat for quick links? item[0] is also not recognized and I get annotation error. So I had to repalce dots with /

UPDATE1 : . Here is another payload tried in Graph explorer. This response is constructed using the fiddler response of PnP.Powershell add-PnpWebpart command.

{
"name": "LinPage1.aspx",
"title": "EriDefault",
"publishingState": {
    "level": "checkout",
    "versionId": "0.1"
},
"webParts": [
    {
        "type": "c70391ea-0b10-4ee9-b2b4-006d3fcad0cd",
        "data": {
            "title": "Quick links",
            "description": "Quick links",
            "dataVersion": "2.0",
            "properties": {
                "items": [
                    {
                        "sourceItem": {
                            "progId": "",
                            "url": "https://www.google.com",
                            "itemType": 2,
                            "fileExtension": ""
                        },
                        "thumbnailType": 3,
                        "title": "Google",
                        "id": 2
                    },
                    {
                        "sourceItem": {
                            "progId": "",
                            "url": "https://www.youtube.com",
                            "itemType": 2,
                            "fileExtension": ""
                        },
                        "thumbnailType": 3,
                        "title": "Youtube",
                        "id": 1
                    }
                ],
                "isMigrated": true,
                "layoutId": "CompactCard",
                "layoutComponentId": "706e33c8-af37-4e7b-9d22-6e5694d92a6f",
                "shouldShowThumbnail": true,
                "title": "QuickLinks 2",
                "hideWebPartWhenEmpty": "true"
            },
            "dynamicDataPaths": {},
            "dynamicDataValues": {},
            "serverProcessedContent": {}
        }
    }
]

}

Getting same error. Complaining about forEach. Not sure why this json is getting converted to invalid JSON. Please note, Page does get created qith quick links. However, quick links is showing error shown in screenshot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.