Answers.Body: <p>There is an issue with the contribution 'source' field being accessed through the API, due to there being a conflict between the 'source' field of a contribution and the 'source' field of a contact.</p>
  
  <p>To get around this conflict, add the prefix 'contribution_'. So in the API call, change 'source' to 'contribution_source':</p>
  
  <pre><code>$result = civicrm_api3('Contribution', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; "source",
    'id' =&gt; 1,
  ));
  </code></pre>
  
  <p>...becomes...</p>
  
  <pre><code>$result = civicrm_api3('Contribution', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; "contribution_source",
    'id' =&gt; 1,
  ));
  </code></pre>
  
  <p>This worked for me.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-30T12:48:04.580Z
Answers.LastActivityDate: 2016-11-30T12:48:04.580Z
Answers.UserDisplayName: Rich Smith
Body: <p>On CiviCRM 4.6.11.
  I need to get the source field of a contribution, but the api seems to fail.
  Testing the API on <a href="http://xxx//civicrm/api#explorer" rel="nofollow">http://xxx//civicrm/api#explorer</a> with entries giving the following PHP code :</p>
  
  <pre>
  $result = civicrm_api3('Contribution', 'get', array(
    'sequential' => 1,
    'return' => "source",
    'contact_id' => 4889,
  ));
  </pre>
  
  <p>gives as results :</p>
  
  <pre>
  {
      "is_error": 0,
      "version": 3,
      "count": 1,
      "id": 4676,
      "values": [
          {
              "contact_id": "4889",
              "contribution_id": "4676",
              "id": "4676"
          }
      ]
  }
  </pre>
  
  <p>Although the contribution DO HAVE a source value, no source entry in the result.
  Is-it a knonw bug, or what wrong in the trequest ?</p>
  
  <p>Thanks for help.</p>
  
  <p>Jean-Pierre</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-11-30T09:26:51.183Z
Comments.Text: Did you ever manage to work out how to return the source value? I'm having exactly the same problem.
Comments.UserDisplayName: Rich Smith
Tags: <api><contributions>
Title: Impossible to get the source field with the Contribution API
ThreadText: # Impossible to get the source field with the Contribution API
  
  (Asked by: username_0 on 2016-10-12)
  
  On CiviCRM 4.6.11.
  I need to get the source field of a contribution, but the api seems to fail.
  Testing the API on http://xxx//civicrm/api#explorer with entries giving the following PHP code :
  
  $result = civicrm_api3('Contribution', 'get', array(
    'sequential' => 1,
    'return' => "source",
    'contact_id' => 4889,
  ));
  
  gives as results :
  
  {
      "is_error": 0,
      "version": 3,
      "count": 1,
      "id": 4676,
      "values": [
          {
              "contact_id": "4889",
              "contribution_id": "4676",
              "id": "4676"
          }
      ]
  }
  
  Although the contribution DO HAVE a source value, no source entry in the result.
  Is-it a knonw bug, or what wrong in the trequest ?
  Thanks for help.
  Jean-Pierre
  
  **Tags:** api, contributions
  
  > **Comments:**
  > **username_1**: Did you ever manage to work out how to return the source value? I'm having exactly the same problem.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-11-30. Score: 2 | Accepted answer
  
  There is an issue with the contribution 'source' field being accessed through the API, due to there being a conflict between the 'source' field of a contribution and the 'source' field of a contact.
  To get around this conflict, add the prefix 'contribution_'. So in the API call, change 'source' to 'contribution_source':
  $result = civicrm_api3('Contribution', 'get', array(
    'sequential' => 1,
    'return' => "source",
    'id' => 1,
  ));
  
  ...becomes...
  $result = civicrm_api3('Contribution', 'get', array(
    'sequential' => 1,
    'return' => "contribution_source",
    'id' => 1,
  ));
  
  This worked for me.
  
  
  ---
  
  