question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug report: add webpart with properties not working

See original GitHub issue

Description

Hi Team, i am trying to add webpart on modern page with pre-configured properties, but not working. i have used below lines from https://pnp.github.io/

m365 --% spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap --webPartProperties “{”“Title”“:”“Foo location”“}”``

m365 spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart Image --webPartData '{ “dataVersion”: “1.8”, “serverProcessedContent”: {“htmlStrings”:{},“searchablePlainTexts”:{“captionText”:“”},“imageSources”:{“imageSource”:“/sites/team-a/SiteAssets/work-life-balance.png”},“links”:{}}, “properties”: {“imageSourceType”:2,“altText”:“a group of people on a beach”,“overlayText”:“Work life balance”,“fileName”:“48146-OFF12_Justice_01.png”,“siteId”:“27664b85-067d-4be9-a7d7-89b2e804d09f”,“webId”:“a7664b85-067d-4be9-a7d7-89b2e804d09f”,“listId”:“37664b85-067d-4be9-a7d7-89b2e804d09f”,“uniqueId”:“67664b85-067d-4be9-a7d7-89b2e804d09f”,“imgWidth”:650,“imgHeight”:433,“fixAspectRatio”:false,“isOverlayTextEnabled”:true}}'

using these lines not able to add standard webpart on the page.

Steps to reproduce

$webPartPropsJson = '{"id":"c70391ea-0b10-4ee9-b2b4-006d3fcad0cd","instanceId":"0683c254-92c4-4a96-adad-dd9fab9a61e0","title":"Quick links","description":"Show a collection of links to content such as documents, images, videos, and more in a variety of layouts with options for icons, images, and audience targeting.","audiences":[],"serverProcessedContent":{"htmlStrings":{},"searchablePlainTexts":{"items[0].title":"Google"},"imageSources":{},"links":{"baseUrl":"https://ajayguptavf.sharepoint.com/sites/mdrndev-comm","items[0].sourceItem.url":"https://google.com"},"componentDependencies":{"layoutComponentId":"706e33c8-af37-4e7b-9d22-6e5694d92a6f"}}}'
Write-Host $webPartPropsJson
# Make sure to add the backticks, double the JSON double-quotes and escape double quotes in properties'values
$webPartPropsJson = '`"{0}"`' -f $webPartPropsJson.Replace('\','\\').Replace('"', '""')


m365  spo page clientsidewebpart add --webUrl $siteUrl --pageName $pageName --standardWebPart QuickLinks --webPartData $webPartPropsJson --debug

Expected results

page created with webpart added in it.

Actual results

Error: Specified webPartData is not a valid JSON string. Input: {"id":"c70391ea-0b10-4ee9-b2b4-006d3fcad0cd","instanceId":"0683c254-92c4-4a96-adad-dd9fab9a61e0","title":"Quick links","description":"Show a collection of links to content such as documents, images, videos, and more in a variety of layouts with options for icons, images, and audience targeting.","audiences":[],"serverProcessedContent":{"htmlStrings":{},"searchablePlainTexts":{"items[0].title":"Google"},"imageSources":{},"links":{"baseUrl":"https://ajayguptavf.sharepoint.com/sites/mdrndev-comm","items[0].sourceItem.url":"https://google.com"},"componentDependencies":{"layoutComponentId":"706e33c8-af37-4e7b-9d22-6e5694d92a6f"}}}. Error: SyntaxError: Unexpected token ` in JSON at position 0

Diagnostics

No response

CLI for Microsoft 365 version

v4.3.0

nodejs version

v12.16.1

Operating system (environment)

Windows

Shell

PowerShell

cli doctor

No response

Additional Info

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
ag0059985commented, Jan 19, 2022

@arjunumenon will post an update once I have tested in windows. Anyway thanks for quick responses @waldekmastykarz @arjunumenon

3reactions
arjunumenoncommented, Jan 18, 2022

Hello @ag0059985 - I had tried recreating the issue in Windows 10 with PowerShell Version 5.1.18362. If you modify your script based on @waldekmastykarz 's suggestion by removing the outer backticks, it is working as expected. image

Please let us know if you are still facing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sharepoint Online List Properties WebPart stopped working?
Hi I have a list and list properties webpart configured and I've noticed that they have stopped work recently (I'd guess in the...
Read more >
Cannot add ReportViewer Webpart via Powershell to Page
I found a working solution. The ReportViewerWebPart needs an additional context. Can anyone tell me, where this is documented? Whatever, here is my...
Read more >
Solution: Power BI report pages not showing up as options for ...
To fix this and have your pages show up as options in the dropdown, simply remove the ReportSection1 (or 2, 3, etc.) from...
Read more >
Confirmed by MS: Bug in the News Web Part - SharePointBabe
But the problem has been there for a week so that is not likely. You can of course go into the news article,...
Read more >
One of the Properties of the Web Part has an Incorrect Format
Web Part Error : One of the properties of the Web Part has an incorrect format. Windows SharePoint Services cannot deserialize the Web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found