Answers.Body: <p>Not everyone else use only the json, I find it easier to read and fix to use separate params ;)</p>
  
  <p>I think the error is on the json you provide is not correct. Instead of:</p>
  
  <p>["sequential"=>1,"return"=>"id,do_not_mail","external_identifier"=>777]</p>
  
  <p>it should be</p>
  
  <p>{"sequential":1,"return":"id,do_not_mail","external_identifier":777}</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-03T12:14:52.527Z
Answers.Text: I also do not like or use the json, I also prefer the separate params. Must be an age thing Xavier :-)
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-11T10:13:12.837Z
Answers.LastActivityDate: 2017-06-11T10:13:12.837Z
Answers.UserDisplayName: Xavier
Body: <p>I am having two issues w/ the REST api via curl.</p>
  
  <p>1) API is ignoring json attribute.   If I do not urlencode, I get a "Unable to decode supplied JSON" return msg.   When I do encode, as shown below, I get past issue, but it seems to ignore any of the conditions set in json attrib.  It just return all contacts,  w/out restricting by external_identifier or applying return filters set in json object. </p>
  
  <pre><code>$curl_post_data = [
      'debug' =&gt; 1,
      'version' =&gt; 3,
      'entity' =&gt; 'Contact',
      'action' =&gt; 'get',
      'json' =&gt; urlencode (json_encode ( ["sequential"=&gt;1,"return"=&gt;"id,do_not_mail","external_identifier"=&gt;777] )),
      'api_key' =&gt; '1234',
      'key' =&gt; '1234',
  ];
  </code></pre>
  
  <p>If I take out conditions &amp; filters out of json attrib, it works fine :</p>
  
  <pre><code>$curl_post_data = [
      'debug' =&gt; 1,
      'version' =&gt; 3,
      'entity' =&gt; 'Contact',
      'action' =&gt; 'get',
      'json' =&gt; 1,
      'api_key' =&gt; '1234',
      'key' =&gt; '1234',
      'external_identifier' =&gt; 777,
      'return'=&gt; 'id,do_not_mail'
  ];
  </code></pre>
  
  <p>However, everyone else seems to be using this json attrib. I would like to get that working.</p>
  
  <p>2) Second issue is chaining.</p>
  
  <pre><code>$curl_post_data = [
      'debug' =&gt; 1,
      'version' =&gt; 3,
      'entity' =&gt; 'Contact',
      'action' =&gt; 'get',
      'json' =&gt; 1,
      'api_key' =&gt; '1234',
      'key' =&gt; '1234',
      'external_identifier' =&gt; 777,
      'return'=&gt; 'id,do_not_mail',
      'api.Contact.create' =&gt; urlencode (json_encode(['do_not_mail'=&gt;0]))
  ];
  </code></pre>
  
  <p>Using api.Contact.create / replace, etc will trigger an undefined field error : undefined_fields":["api_Contact_create"].</p>
  
  <p>I am json_encoding the field value in this example, but get the same issue by just passing an array.   It just doesn't seem to recognize the chaining directive at all.</p>
  
  <p>Any help much appreciated.</p>
  
Tags: <api><rest>
Title: REST API - json and chaining issues
ThreadText: # REST API - json and chaining issues
  
  (Asked by: username_0 on 2017-06-06)
  
  I am having two issues w/ the REST api via curl.
  
  1) API is ignoring json attribute. If I do not urlencode, I get a "Unable to decode supplied JSON" return msg. When I do encode, as shown below, I get past issue, but it seems to ignore any of the conditions set in json attrib. It just return all contacts, w/out restricting by external\_identifier or applying return filters set in json object.
  
  ```
  $curl_post_data = [
      'debug' => 1,
      'version' => 3,
      'entity' => 'Contact',
      'action' => 'get',
      'json' => urlencode (json_encode ( ["sequential"=>1,"return"=>"id,do_not_mail","external_identifier"=>777] )),
      'api_key' => '1234',
      'key' => '1234',
  ];
  
  ```
  
  If I take out conditions & filters out of json attrib, it works fine :
  
  ```
  $curl_post_data = [
      'debug' => 1,
      'version' => 3,
      'entity' => 'Contact',
      'action' => 'get',
      'json' => 1,
      'api_key' => '1234',
      'key' => '1234',
      'external_identifier' => 777,
      'return'=> 'id,do_not_mail'
  ];
  
  ```
  
  However, everyone else seems to be using this json attrib. I would like to get that working.
  
  2) Second issue is chaining.
  
  ```
  $curl_post_data = [
      'debug' => 1,
      'version' => 3,
      'entity' => 'Contact',
      'action' => 'get',
      'json' => 1,
      'api_key' => '1234',
      'key' => '1234',
      'external_identifier' => 777,
      'return'=> 'id,do_not_mail',
      'api.Contact.create' => urlencode (json_encode(['do_not_mail'=>0]))
  ];
  
  ```
  
  Using api.Contact.create / replace, etc will trigger an undefined field error : undefined\_fields":["api\_Contact\_create"].
  
  I am json\_encoding the field value in this example, but get the same issue by just passing an array. It just doesn't seem to recognize the chaining directive at all.
  
  Any help much appreciated.
  
  **Tags:** api, rest
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-11. Score: 1
  
  Not everyone else use only the json, I find it easier to read and fix to use separate params ;)
  
  I think the error is on the json you provide is not correct. Instead of:
  
  ["sequential"=>1,"return"=>"id,do\_not\_mail","external\_identifier"=>777]
  
  it should be
  
  {"sequential":1,"return":"id,do\_not\_mail","external\_identifier":777}
  
  > **Comments:**
  > **username_2**: I also do not like or use the json, I also prefer the separate params. Must be an age thing username_1 :-)  
  
  ---
  
  