Answers.Body: <p>Instead of</p>
  
  <pre><code>'financial_type_id' =&gt; array("Campaign Contribution", "Donation")
  </code></pre>
  
  <p>try</p>
  
  <pre><code>'financial_type_id' =&gt; array('IN' =&gt; array("Campaign Contribution", "Donation"))
  </code></pre>
  
  <p>The API Explorer can generate this code for you if you select the IN operator.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T00:34:21.390Z
Answers.Text: Yeah, I think that works...but the new API Explorer version generates the incorrect code in my initial post (I don't think it did that on 4.6.0, though I could be wrong.)
  
  I'm waiting for 4.6.3 to fix the bug of Contribution get not using a specified contact ID as a filter, before continuing to troubleshoot the area where this is a problem for us.
Answers.UserDisplayName: Norris
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T13:44:05.683Z
Answers.Text: I'm pretty sure the explorer will generate the above (correct) code if you select the "IN" operator. This is generally (but not always) the way to pass multiple values to a "get" operation. Some apis are not entirely consistent with this, hence the explorer's ability to generate code in either format.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-17T21:02:57.557Z
Answers.LastActivityDate: 2015-05-18T19:35:24.310Z
Answers.LastEditDate: 2015-05-18T19:35:24.310Z
Answers.UserDisplayName: Coleman
Body: <p>I have this problem on my Joomla 4.6.2 system, and can reproduce it on the Joomla sandbox.  If I use the API Explorer to build a query like:</p>
  
  <pre><code>$result = civicrm_api3('Contribution', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; "id",
    'contact_id' =&gt; 2,
    'financial_type_id' =&gt; "Campaign Contribution",
  ));
  </code></pre>
  
  <p>it works OK.  But if I try to specify multiple possible values for financial_type_id, such as:</p>
  
  <pre><code>$result = civicrm_api3('Contribution', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; "id",
    'contact_id' =&gt; 2,
    'financial_type_id' =&gt; array("Campaign Contribution", "Donation"),
  ));
  </code></pre>
  
  <p>it generates a SQL error because it creates an invalid WHERE clause:</p>
  
  <pre><code>WHERE  ( civicrm_contribution.is_test = 0 AND civicrm_contribution.financial_type_id 0 )  AND (contact_a.is_deleted = 0)  LIMIT 0, 25 
  </code></pre>
  
  <p>The "civicrm_contribution.financial_type_id 0" should instead be something like "civicrm_contribution.financial_type_id IN (1, 2)"</p>
  
  <p>Is this a bug?</p>
  
Tags: <civicontribute><api><contributions>
Title: Why doesn't API for Contribution Get work with multiple Financial Type ID values?
ThreadText: # Why doesn't API for Contribution Get work with multiple Financial Type ID values?
  
  (Asked by: username_0 on 2015-05-17)
  
  I have this problem on my Joomla 4.6.2 system, and can reproduce it on the Joomla sandbox.  If I use the API Explorer to build a query like:
  $result = civicrm_api3('Contribution', 'get', array(
    'sequential' => 1,
    'return' => "id",
    'contact_id' => 2,
    'financial_type_id' => "Campaign Contribution",
  ));
  
  it works OK.  But if I try to specify multiple possible values for financial_type_id, such as:
  $result = civicrm_api3('Contribution', 'get', array(
    'sequential' => 1,
    'return' => "id",
    'contact_id' => 2,
    'financial_type_id' => array("Campaign Contribution", "Donation"),
  ));
  
  it generates a SQL error because it creates an invalid WHERE clause:
  WHERE  ( civicrm_contribution.is_test = 0 AND civicrm_contribution.financial_type_id 0 )  AND (contact_a.is_deleted = 0)  LIMIT 0, 25 
  
  The "civicrm_contribution.financial_type_id 0" should instead be something like "civicrm_contribution.financial_type_id IN (1, 2)"
  Is this a bug?
  
  **Tags:** civicontribute, api, contributions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-05-17. Score: 3 | Accepted answer
  
  Instead of
  'financial_type_id' => array("Campaign Contribution", "Donation")
  
  try
  'financial_type_id' => array('IN' => array("Campaign Contribution", "Donation"))
  
  The API Explorer can generate this code for you if you select the IN operator.
  
  > **Comments:**
  > **username_0**: Yeah, I think that works...but the new API Explorer version generates the incorrect code in my initial post (I don't think it did that on 4.6.0, though I could be wrong.)  I'm waiting for 4.6.3 to fix the bug of Contribution get not using a specified contact ID as a filter, before continuing to troubleshoot the area where this is a problem for us.  
  > **username_1**: I'm pretty sure the explorer will generate the above (correct) code if you select the "IN" operator. This is generally (but not always) the way to pass multiple values to a "get" operation. Some apis are not entirely consistent with this, hence the explorer's ability to generate code in either format.  
  
  ---
  
  