I used the API explorer to create a target url, but I cannot send a GET request with curl. The error is: "Failed to authenticate key".
Here are the steps I am following:
- Create an url in the API explorer:
http://51.15.94.180/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=get&api_key=userkey&key=sitekey&json={"sequential":1}
Looked up the site key in civicrm.settings.php (under
CIVICRM_SITE_KEY
)Used the "API Key" extention to add an API key to the "admin" contact (the one that is associated with the civicrm admin account).
I inserted my keys (which I change here for security reasons) to produce this expanded url:
http://51.15.94.180/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=get&api_key=uCMXIUhzpPv&key=VKtUrOkd&json={"sequential":1}
- I
curl
this url, and get the mentioned error
Can anybody help?
UPDATE
I was able to stick a debug log statement into the authenticateKey
function of System.php
:
CRM_Core_Error::debug_var("req", $_REQUEST);
CRM_Core_Error::debug_var("req size", sizeof($_REQUEST));
The result of this is:
Mar 21 11:49:21 [info] $req = Array
(
[entity] => Contact
)
Mar 21 11:49:21 [info] $req size = 1
So it seems only the first key/val pair of the request is received in _REQUEST. How can this happen?