Answers.Body: <p>It should be 'case_id' => 223 instead of 'id' => 223 for the CaseContact one. It seems to work with either on the public demo, but that might be coincidence - in the civicrm_case_contact table the 'id' field is an autoincrement technically unrelated to case_id, but may or may not match the case_id depending on creation order, multiple clients, and other happenings.</p>
  
  <p>I would use 'case_id', like so</p>
  
  <p><code>$result = civicrm_api3('CaseContact', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; array("contact_id"),
    'case_id' =&gt; 223,
  ));</code> </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-09T03:16:30.893Z
Answers.LastActivityDate: 2017-07-09T03:16:30.893Z
Answers.UserDisplayName: Demerit
Body: <p>Right now I am using the API Explorer (in 4.7.21) just to get the pieces I need for some custom code in Drupal.  I am just very confused about what the API Explorer is returning.  I am guessing this me not a bug. </p>
  
  <p>If I execute the following with the Case ID of 223 then I should get back the contact assigned to that case.  </p>
  
  <pre><code>$result = civicrm_api3('CaseContact', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; array("contact_id"),
    'id' =&gt; 223,
  )); 
  </code></pre>
  
  <p>When I execute this I get the contact for case 224.  </p>
  
  <p>If I use the API to query for the <em>Subject</em> of the case for ID 223 I get the expected results and the same for 224. </p>
  
  <pre><code>$result = civicrm_api3('Case', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; array("subject"),
    'id' =&gt; 223,
  ));
  </code></pre>
  
  <p>If anyone sees my error here I would appreciate it. If this is a bug I am glad to put it only issues.civicrm.org.</p>
  
  <p>Thanks! </p>
  
Tags: <api><civicase>
Title: Confused About API Results
ThreadText: # Confused About API Results
  
  (Asked by: username_0 on 2017-07-09)
  
  Right now I am using the API Explorer (in 4.7.21) just to get the pieces I need for some custom code in Drupal. I am just very confused about what the API Explorer is returning. I am guessing this me not a bug.
  
  If I execute the following with the Case ID of 223 then I should get back the contact assigned to that case.
  
  ```
  $result = civicrm_api3('CaseContact', 'get', array(
    'sequential' => 1,
    'return' => array("contact_id"),
    'id' => 223,
  )); 
  
  ```
  
  When I execute this I get the contact for case 224.
  
  If I use the API to query for the *Subject* of the case for ID 223 I get the expected results and the same for 224.
  
  ```
  $result = civicrm_api3('Case', 'get', array(
    'sequential' => 1,
    'return' => array("subject"),
    'id' => 223,
  ));
  
  ```
  
  If anyone sees my error here I would appreciate it. If this is a bug I am glad to put it only issues.civicrm.org.
  
  Thanks!
  
  **Tags:** api, civicase
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-09. Score: 1 | Accepted answer
  
  It should be 'case\_id' => 223 instead of 'id' => 223 for the CaseContact one. It seems to work with either on the public demo, but that might be coincidence - in the civicrm\_case\_contact table the 'id' field is an autoincrement technically unrelated to case\_id, but may or may not match the case\_id depending on creation order, multiple clients, and other happenings.
  
  I would use 'case\_id', like so
  
  `$result = civicrm_api3('CaseContact', 'get', array(
  'sequential' => 1,
  'return' => array("contact_id"),
  'case_id' => 223,
  ));`
  
  
  ---
  
  