Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clasp run [functionName] --params doesn't work #742

Open
JRPoinsot opened this issue Feb 26, 2020 · 6 comments
Open

clasp run [functionName] --params doesn't work #742

JRPoinsot opened this issue Feb 26, 2020 · 6 comments

Comments

@JRPoinsot
Copy link

(Note: Non-breaking issues are likely not to be prioritized. Please consider a PR in addition to your issue)

Expected Behavior

clasp run setProperties --params '[{"foo":"bar"}]'
Should be execute my function setProperties with a Object {"foo": "bar"}

My function :
function setProperties(properties) {
PropertiesService.getScriptProperties.setProperties(properties, false);
}

Actual Behavior

response : Input params not Valid JSON string. Please fix and try again.
A try other basic JSON format ... but same message.

Specifications

  • Node version (node -v): v10.16.3
  • Version (clasp -v): 2.3.0
  • OS (Mac/Linux/Windows): Windows
@imthenachoman
Copy link

Silly question but what happens if you use double quotes:?

clasp run setProperties --params "[{'foo':'bar'}]"

@ChaddPortwine
Copy link

ChaddPortwine commented Feb 12, 2021

I had clasp run setProperty -p ["domain" "mydomain.com"] working a few days ago. It was great.

Now, I cannot find the proper JSON format. I read here to use "...space-separated array of values such...". So I don't know what could have gone wrong?

Here is what I tried:

PC:AppsScript-CLASP user$ clasp run setProperty -p ["domain" "mydomain.com"]
Input params not Valid JSON string. Please fix and try again
PC:AppsScript-CLASP user$ clasp run setProperty -p ["domain","mydomain.com"]
Input params not Valid JSON string. Please fix and try again
PC:AppsScript-CLASP user$ clasp run setProperty -p ['domain','mydomain.com']
Input params not Valid JSON string. Please fix and try again
PC:AppsScript-CLASP user$ clasp run setProperty -p ['domain' 'mydomain.com']
Input params not Valid JSON string. Please fix and try again
PC:AppsScript-CLASP user$ clasp run setProperty -p [{'domain': 'mydomain.com'}]
Input params not Valid JSON string. Please fix and try again
PC:AppsScript-CLASP user$ clasp run setProperty -p "['domain' 'mydomain.com']"
Input params not Valid JSON string. Please fix and try again
PC:AppsScript-CLASP user$ clasp run setProperty -p '['domain' 'mydomain.com']'
Input params not Valid JSON string. Please fix and try again

Node v8.11.1
Clasp v2.3.0
MacOs BigSur v11.2.1

Update

The JSON format that works for me: '["domain","mydomain.com"]'

Additionally, I needed to run node LTS, and I was behind.

@PopGoesTheWza
Copy link
Collaborator

Just to be sure the issue still exist, can you try replacing @google/clasp 2.3.0 with forked-clasp which is more advanced?

npm uninstall -g @google/clasp
npm install -g forked-clasp

@somombo
Copy link

somombo commented Jun 24, 2021

I noticed that there's not a single test case in https://github.com/google/clasp/blob/master/test/commands/run.ts
for --params

@Claudiney-Santos
Copy link

Claudiney-Santos commented Jul 17, 2021

I had the same problem.

I use windows cmd, so the parameter was "splited" because of the double quotes
Cmd does not use single quotes, so I used \" instead and it worked

The correct code was something like this:
clasp run "myFunction" -p "[\"test\"]"

@s6fcda
Copy link

s6fcda commented Aug 23, 2022

I use windows cmd, so the parameter was "splited" because of the double quotes Cmd does not use single quotes, so I used \" instead and it worked

The correct code was something like this: clasp run "myFunction" -p "[\"test\"]"

@Claudiney-Santos
I know this was an old reply, but thanks for pointing this out. This solved my problem.
I hope this is included in the formal documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants