Answers.Body: <p>The correct endpoint for WordPress is <code>wp-json/civicrm/v3/rest</code>. Its documented in the developer manual, see <a href="https://docs.civicrm.org/dev/en/latest/api/v3/wp-rest/#endpoints" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/api/v3/wp-rest/#endpoints</a>.   When you just copy the URL that is suggested in the API explorer you are left in the dark.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-23T16:28:54.403Z
Answers.LastActivityDate: 2021-02-23T16:28:54.403Z
Answers.UserDisplayName: Kainuk - CiviCooP
Body: <p>This is my first post for CiviCRM.</p>
  
  <p>Hi to all.</p>
  
  <p>I have seen others post related and nowadays the problem remain.</p>
  
  <p>Different from this post: 
  <a href="https://civicrm.stackexchange.com/questions/6585/rest-api-unable-to-decode-supplied-json">REST API: Unable to decode supplied JSON</a>
   - with wordpress I got always the same response "<strong>Unable to decode supplied JSON</strong>".</p>
  
  <p>I tried clear installation with Joomla and also Backdrop, and both works correctly.</p>
  
  <p>I am not a good programmer but I tried to do some stuff myself, here you what I prepared on my little server:</p>
  
  <p>WordPress+CiviCRM with the problem: <a href="http://144.91.105.68/cms/wordpress/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=a42bfc2b33cf13184711bff14fe1fb19&amp;key=a42bfc2b33cf13184711bff14fe1fb19&amp;json=%7B%22sequential%22:1%7D" rel="nofollow noreferrer">link clear installation</a></p>
  
  <p>WordPress+CiviCRM fixed myself: <a href="http://144.91.105.68/cms/cust/wordpress/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=a42bfc2b33cf13184711bff14fe1fb19&amp;key=a42bfc2b33cf13184711bff14fe1fb19&amp;json=%7B%22sequential%22:1%7D" rel="nofollow noreferrer">custom</a></p>
  
  <p>Here you what I modified to the file REST.php...</p>
  
  <p>after line 326</p>
  
  
  
  <pre><code>    if (array_key_exists('json', $requestParams) &amp;&amp; $requestParams['json'][0] == "{") {
        $params = json_decode($requestParams['json'], TRUE);
  </code></pre>
  
  <p>my modification start here</p>
  
  
  
  <pre><code>      $new_requestParams= $requestParams['json'];
  
        $new_requestParams= str_replace("\\", "", $new_requestParams);
        $new_requestParams= str_replace("\\", "", $new_requestParams);
  
        $params = json_decode($new_requestParams, TRUE);
  </code></pre>
  
  <p>I practically saw a lot of "\" before the JSON DECODE.</p>
  
  <p>So removing this "\" now works regularly.</p>
  
  <p>If you wish can check directly on both sites:
  Clear ----> <a href="http://144.91.105.68/cms/wordpress" rel="nofollow noreferrer">http://144.91.105.68/cms/wordpress</a></p>
  
  <p>Custom ---> <a href="http://144.91.105.68/cms/cust/wordpress" rel="nofollow noreferrer">http://144.91.105.68/cms/cust/wordpress</a></p>
  
  <p>The user and password are both same:   <strong>admin</strong> / <strong>admin</strong></p>
  
  <p>And also siteKey and api_key are always:  <strong>a42bfc2b33cf13184711bff14fe1fb19</strong></p>
  
  <p>Regards Roberto T.</p>
  
Tags: <wordpress><api><rest><json>
Title: Only in WORDPRESS: REST.php ---> Unable to decode supplied JSON
ThreadText: # Only in WORDPRESS: REST.php ---> Unable to decode supplied JSON
  
  (Asked by: username_0 on 2020-06-14)
  
  This is my first post for CiviCRM.
  Hi to all.
  I have seen others post related and nowadays the problem remain.
  Different from this post: 
  REST API: Unable to decode supplied JSON
   - with wordpress I got always the same response "Unable to decode supplied JSON".
  I tried clear installation with Joomla and also Backdrop, and both works correctly.
  I am not a good programmer but I tried to do some stuff myself, here you what I prepared on my little server:
  WordPress+CiviCRM with the problem: link clear installation
  WordPress+CiviCRM fixed myself: custom
  Here you what I modified to the file REST.php...
  after line 326
      if (array_key_exists('json', $requestParams) && $requestParams['json'][0] == "{") {
        $params = json_decode($requestParams['json'], TRUE);
  
  my modification start here
        $new_requestParams= $requestParams['json'];
  
        $new_requestParams= str_replace("\\", "", $new_requestParams);
        $new_requestParams= str_replace("\\", "", $new_requestParams);
  
        $params = json_decode($new_requestParams, TRUE);
  
  I practically saw a lot of "\" before the JSON DECODE.
  So removing this "\" now works regularly.
  If you wish can check directly on both sites:
  Clear ----> http://144.91.105.68/cms/wordpress
  Custom ---> http://144.91.105.68/cms/cust/wordpress
  The user and password are both same:   admin / admin
  And also siteKey and api_key are always:  a42bfc2b33cf13184711bff14fe1fb19
  Regards Roberto T.
  
  **Tags:** wordpress, api, rest, json
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-02-23. Score: 2
  
  The correct endpoint for WordPress is `wp-json/civicrm/v3/rest`. Its documented in the developer manual, see <https://docs.civicrm.org/dev/en/latest/api/v3/wp-rest/#endpoints>. When you just copy the URL that is suggested in the API explorer you are left in the dark.
  
  
  ---
  
  