google-apps-scriptgoogle-apps-script-apiclasp

How to use clasp run with properties - the valid JSON format


Why does this clasp command no longer work for me?

clasp run setProperty -p ['domain' 'mydomain.com']

which runs this function

function setProperty(key,value) {
    let scriptProperties = PropertiesService.getScriptProperties()
    scriptProperties.setProperty(key,value)
};
PC:AppsScript-CLASP user$ clasp run setProperty -p ['domain' 'mydomain.com']
Input params not Valid JSON string. Please fix and try again

Is this an issue with my system or the packages?

I'm using


Solution

  • You forgot a comma and single quotes

    As per the example in the documentation you must use single quotes outside the array and double quotes when using a string clasp run 'setProperty' -p '["domain", "mydomain.com"]'.

    Reference