Answers.Body: <p>I'm pretty sure you're running into the same problem I've documented on Gitlab as <a href="https://lab.civicrm.org/dev/core/issues/298" rel="nofollow noreferrer">issue #298</a> - basically, API Explorer doesn't return correct code when you need to pass in an array.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-19T19:35:48.060Z
Answers.LastActivityDate: 2018-08-19T19:35:48.060Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>drush cvapi Contact.create contact_type="Individual" contact_sub_type="MySubType" custom_10=[1,2,3] first_name="John" last_name="Doe"  
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>Array
  (
      [error_field] =&gt; custom_10
      [error_code] =&gt; 2001
      [entity] =&gt; Contact
      [action] =&gt; create
      [is_error] =&gt; 1
      [error_message] =&gt; '1,2,3' is not a valid option for field custom_10
  )
  </code></pre>
  
  <p>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?</p>
  
  <p>I have no issues adding anything else Contact wise including chaining for additional emails.  It is just fields that have arrays of data.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-19T15:05:14.557Z
Comments.Text: How about passing array in JSON format?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-20T08:54:24.307Z
Comments.Text: 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!
Comments.UserDisplayName: ChumKui
Tags: <api><drush>
Title: Error using Drush and Civi API when adding data to a custom field with multi-select data
ThreadText: # Error using Drush and Civi API when adding data to a custom field with multi-select data
  
  (Asked by: username_0 on 2018-08-19)
  
  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:
  
  ```
  Array
  (
      [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.
  
  **Tags:** api, drush
  
  > **Comments:**
  > **username_1**: How about passing array in JSON format?  
  > **username_0**: username_1 - 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!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-08-19. Score: 0 | Accepted answer
  
  I'm pretty sure you're running into the same problem I've documented on Gitlab as [issue #298](https://lab.civicrm.org/dev/core/issues/298) - basically, API Explorer doesn't return correct code when you need to pass in an array.
  
  
  ---
  
  