I have been trying to create contacts data using Drush and the CiviAPI. I get an error when I try to add data to a multi-select field despite using exactly the same syntax that the API explorer gives me.

I have a custom field (machine name: custom_10) that takes up to 5 options. As an example, If I use the API explorer to create the following output, I get this:

drush cvapi Contact.create contact_type="Individual" contact_sub_type="MySubType" custom_10=[1,2,3] first_name="John" last_name="Doe"  

Executing this though the API explore works fine, but if I copy the drush line and execute it, the array data for custom_10 causes an error:

    [error_field] => custom_10
    [error_code] => 2001
    [entity] => Contact
    [action] => create
    [is_error] => 1
    [error_message] => '1,2,3' is not a valid option for field custom_10

executing a single option with custom_10=1 will work fine. I have tried various different syntax but cannot get it to take. Has anyone else had this issue with the Drush approach for arrays in Custom fields?

I have no issues adding anything else Contact wise including chaining for additional emails. It is just fields that have arrays of data.

  • 2
    How about passing array in JSON format? Aug 19, 2018 at 15:05
  • 1
    Pradeep - you are absolutely right, my initial comment below was wrong and I have deleted it. I have now tried this and amended my output to pass in JSON arrays and it seems to work OK. Many thanks for this!
    – ChumKui
    Aug 20, 2018 at 8:54

1 Answer 1


I'm pretty sure you're running into the same problem I've documented on Gitlab as issue #298 - basically, API Explorer doesn't return correct code when you need to pass in an array.


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.