2

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. – Kainuk - CiviCooP Dec 27 '16 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 – ErichBSchulz Dec 27 '16 at 21:45
1

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 :-) – ErichBSchulz Dec 30 '16 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 Jan 1 '17 at 16:05
  • 1
    I would think adding cv but not removing drush makes sense – user4278 May 15 '17 at 22:37
6

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, privacy policy and cookie policy

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