1

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.