I'm building API extension that takes complex objects as parameters.

The API exporer does a brilliant job at parsing the objects, but drush less so.

Commands I am trying are:

`drush @contact cvapi Contact.getclif sequential=1 return="id" clif={"type":"raw","params":{"5":1,"6":1}} length=5`

`drush @contact cvapi Contact.getclif sequential=1 return="id" clif='{"type":"raw","params":{"5":1,"6":1}}' length=5`

Both fail to json_decode the object and my API method receives a JSON string.

I could decode the string in my API - but that feels a little hacky...

Am I doing something wrong?

Screenshot of API explorer showing it working as expected

  • If it is your objective is to execute API commands from the shell you can also use drush php-script. Commented Dec 27, 2016 at 13:41
  • oh right! thanks! thats a good plan @Kainuk - I guess I'm still wondering if this is a bug or user error Commented Dec 27, 2016 at 21:45

2 Answers 2


the drush api command needs to be made "json aware" it seems indeed. It shouldn't be too complicated, want to give it a go and patch it?

  • Thanks @xavier, i'm battling with cv first up... will see how I go! maybe :-) Commented Dec 30, 2016 at 23:23
  • Seems like we are moving toward cv as the standard cli tool over drush so probably ought to update the api explorer to reflect that change.
    – Coleman
    Commented Jan 1, 2017 at 16:05
  • 1
    I would think adding cv but not removing drush makes sense
    – user4278
    Commented May 15, 2017 at 22:37

Here is how to pass an array to drush echo '{"retrieval_parameters":{"jobId":97727336,"filePath":"Raw Recipient Data Export May 15 2017 22-07-43 PM 674.zip"}}' | drush cvapi Omnirecipients.get --in=json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.