0

I am trying to work out a way of presenting contact information from CiviCRM to another server, but am struggling to work out how one would code it. Has anyone got an example of something that works under Drupal 9?

Running https://<server root>/civicrm/ajax/rest?entity=Contact&action=get&api_key=Userkey&key=Sitekey&json={%22contact_type%22:%22Individual%22,%22first_name%22:%22<firstname%22,%22last_name%22:%22lastname22}

gives

{"IP":"fe80::e00a:1010:c022:f80e%9","level":"security","referer":null,"reason":"CSRF suspected","is_error":1,"error_message":"SECURITY ALERT: Ajax requests can only be issued by javascript clients, eg. CRM.api3()."}

so clearly it needs to be called from javascript, presumably on the client.

It would be really helpful if someone had an example of a working script.

1
1

You may need to add below line in .htaccess or nginx config to allow php file be executed

RewriteCond %{REQUEST_URI} !/libraries/civicrm/extern/[a-z]+\.php$

Copy extern directory from civicrm vendor folder into libraries

The rest api url for drupal would look like

https://sitename/libraries/civicrm/core/extern/rest.php

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.