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.

spo customaction set with --clientSideComponentProperties param results in invalid JSON object

See original GitHub issue

Running the command:

o365 spo customaction set -u https://<tenant>.sharepoint.com/sites/<site> -i<id> -s Web -p '{"testMessage":"Test message"}'

Results in the following when running the corresponding get command:

o365 spo customaction get -u https://<tenant>.sharepoint.com/sites/<site>-i <id> -s Web -o JSON
ClientSideComponentId        : <id>
ClientSideComponentProperties: '{testMessage:Test message}'
CommandUIExtension           : null
Description                  : null
Group                        : null
Id                           : <customActionId>
ImageUrl                     : null
Location                     : ClientSideExtension.ApplicationCustomizer
Name                         : {<customActionId>}
RegistrationId               : null
RegistrationType             : 0
Rights                       : {"High":"0","Low":"0"}
Scope                        : Web
ScriptBlock                  : null
ScriptSrc                    : null
Sequence                     : 65536
Title                        : <customActionTitle>
Url                          : null
VersionOfUserCustomAction    : 0.9.22.9201

Expected behaviour:

  • The value of the ClientSideComponentProperties property should be a valid JSON object
  • When the value is parsed by SPFx app customizer code that inherits from the BaseApplicationCustomizer object - the properties object should be hydrated with the “testMessage” value.

Observed behaviour:

  • The value of the ClientSideComponentProperties property is not a valid JSON object
  • The value parsed by the SPFx app customizer code inheriting BaseApplicationCustomizer - the properties object has no properties

I suspect the above behaviour might be due to the way a POST to the _api/<scope>/UserCustomActions end point processes the ClientSideComponentProperties payload, and not the way the parameter is parsed by spo customaction set - but wanted to raise it here first to see if there’s anything that can be done in office365-cli

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
waldekmastykarzcommented, Oct 4, 2018

From what I’ve seen, the first part of processing quotes happens already in the shell so if incorrectly quoted JSON string is passed into the CLI, it might be tough to make something out of it.

1reaction
VelinGeorgievcommented, Oct 3, 2018

Here are my findings for tonight: Windows 8.1

o365 spo customaction set --url https://xxx.sharepoint.com/sites/xx --id  815860e5-c83a-43aa-a69c-28a936e2d812 -p '{\"instrumentationKey\":\"58b2b73e-82b5-4808-a969-a18cbbd36999\",\"logLevel\":\"1\",\"testMessage\":\"\"}' 

Works for:

  • cmder (ConEmu [64] (version 171025))
  • Windows command prompt

Does not work for:

  • Windows PowerShell.exe - Error: 500. The body in the request is {"ClientSideComponentProperties":"{"}

I managed to make it work with the Windows PowerShell using:

o365 spo customaction set --url https://xxx.sharepoint.com/sites/xxx --id  81
5860e5-c83a-43aa-a69c-28a936e2d812 -p "{'instrumentationKey':'58b2b73e-82b5-4808-a969-a18cbbd36999','logLevel':'1','test
Message':''}"

Body request is

{"ClientSideComponentProperties":"{'instrumentationKey':'58b2b73e-82b5-4808-a969-a18cbbd36999','logLevel':'1','
testMessage':''}"}

Seems the web service is able to convert single quote successfully, but this is pure luck.

Will keep you posted if I find the secret formula for PowerShell.exe

UPDATE: The node command prompt worked with both (Nodejs v8.9.1):

o365 spo customaction set --url https://xxx.sharepoint.com/sites/xxx --id  815860e5-c83a-43aa-a69c-28a936e2d812 -p '{\"instrumentationKey\":\"58b2b73e-82b5-4808-a969-a18cbbd36999\",\"logLevel\":\"1\",\"testMessage\":\"\"}'

image

o365 spo customaction set --url https://xxx.sharepoint.com/sites/xxx --id  815860e5-c83a-43aa-a69c-28a936e2d812 -p "{'instrumentationKey':'58b2b73e-82b5-4808-a969-a18cbbd36999','logLevel':'1','testMessage':''}"

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

spo customaction set with --clientSideComponentProperties ...
Running the command: o365 spo customaction set -u https:// .sharepoint.com/sites/ -i -s Web -p ... param results in invalid JSON object #625.
Read more >
IonFar.SharePoint.PowerShell
Returns a GUID that represents information about the full name of a person who is referenced in a specified Windows SharePoint Services contact...
Read more >
spfx - How does one pass parameters to SharePoint ...
To set the properties that are passed into a field customizer for a particular list, set the field's ClientSideComponentProperties to the JSON ......
Read more >
Migrating from UserCustomAction to SharePoint Framework ...
Migrate from old "classic" customizations (CustomAction) to the new model based on SharePoint Framework extensions.
Read more >
SharePoint Online: How to Inject Custom CSS in Modern Sites?
sppkg file to tenant App catalog; Activate the SPFx Application customizer to the site through custom action. Step 1: Create a Custom CSS...
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