CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Rest API not responding to queries on some systems
Pages: [1]

Author Topic: Rest API not responding to queries on some systems  (Read 1414 times)

simonium

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
Rest API not responding to queries on some systems
June 15, 2012, 04:52:25 am
Hi There,

We are having a perplexing problem with the Rest API. On certain systems we can run a query against the Rest API and it responds with the respective results.  When making the exact same query to other systems, the results are empty, i.e. The API just sends back blank.

We are usually able to login with API, authentication is usually not a problem (though it is on some systems). The API always returns the user's API key and a session id when the authentication works. 

Here is an example of a query that works on one system and not on another (after having successfully authenticated each time):

http://www.example.com/joomla25/administrator/components/com_civicrm/civicrm/extern/rest.php?q=civicrm/contact/search&key=65d6226dacd90518c0d26edfaef2904b&json=1&api_key=e9a0c4376b3dc9a9b379fe0c09ca39c3&contact_type=individual&offset=0

And just to break that query down:

URLhttp://www.example.com/joomla25/administrator/components/com_civicrm/civicrm/extern/rest.php
api_keye9a0c4376b3dc9a9b379fe0c09ca39c3
contact_typeindividual
json1
key65d6226dacd90518c0d26edfaef2904b
api_keye9a0c4376b3dc9a9b379fe0c09ca39c3
qcivicrm/contact/search

These are the systems that work:

  • Joomla 1.5.25 with CiviCRM 3.4.5
  • Joomla 2.5.4 with CiviCRM 4.0.5
  • Drupal 6.22 with CiviCRM 3.4.8

And these are some of the systems that it doesn't work with:

  • Joomla 1.5.26 with CiviCRM 3.4.8 (actually can't even sign in here, even correct settings)
  • Joomla 2.5.4 with CiviCRM 4.1.2
  • Drupal 6.26 with CiviCRM 3.4.8 (can't sign in here either, all settings correct).
  • Drupal 7.14 with CiviCRM 4.1.0



In each case the application that is making the API calls is exactly the same, and we are just pointing it to different CiviCRM installations, with their respective user account details and site key.  We are tracking the ajax calls and responses each time to make sure they are correct.

Has anyone else out there had a similar problem?  Or could we missing something in terms of CiviCRM configuration or settings?

Any thoughts would be much appreciated . . .

Simon.

Mohit Thakral

  • I’m new here
  • *
  • Posts: 12
  • Karma: 1
  • CiviCRM version: 3.4.5+
  • CMS version: Drupal 6.24
  • MySQL version: 7.2
  • PHP version: 5
Re: Rest API not responding to queries on some systems
June 15, 2012, 06:21:18 am
For 3.4.8+ version of CiviSync you can try to put "version=3" at the end and see.

Regards
Mohit Thakral
Mohit Thakral
www.targetintegration.com

simonium

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
Re: Rest API not responding to queries on some systems
June 15, 2012, 07:02:00 am
Hey Mohit,

I tried your suggestion, and added version=3 to the params but joy I'm afraid :( Still getting a blank response back.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Rest API not responding to queries on some systems
June 17, 2012, 11:54:36 pm
Can you (for the REST calls that will need version=3) also replace the contact_search with contact_get? The contact_search only works with version 2. Let me know if that helps?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Rest API not responding to queries on some systems
June 18, 2012, 12:44:54 am
For reference, the rest syntax on api v3 is

Code: [Select]
URL http://www.example.com/joomla25/administrator/components/com_civicrm/civicrm/extern/rest.php
json 1
key 65d6226dacd90518c0d26edfaef2904b
api_key e9a0c4376b3dc9a9b379fe0c09ca39c3
entity contact
action get
(at least on the latest 4.1 version)

So no q=civicm/entity/action, but two separate params

and I know it has been a bit chaotic to reach this official/proper syntax, mostly because we weren't sure what was the proper syntax before, but also because we have focussed more on the smarty/ajax/php syntax while implementing it

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

simonium

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
Re: Rest API not responding to queries on some systems
June 18, 2012, 01:04:14 am
Hi Erik,

I tried adding the version: 3 param and tested it against one of the systems that work, and got this:

{"is_error":1,"error_message":"API (contact,search) does not exist (join the API team and implement civicrm_api3_contact_search"}

So then tried replacing civicrm/contact/search with civicrm/contact/get and it worked, though still only with the systems that have aalways worked.  It made no difference with the installations that don't work.

Xavier:  thanks for your response, I'll try that and see if solves the problem.

Thanks for the help guys!


Simon.

simonium

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
Re: Rest API not responding to queries on some systems
June 18, 2012, 01:14:03 am
Hi Xavier,

I tried your suggestion, changing the syntax of the url, and adding parameters for entity and action, as so: (I've placed each parameter on a new line for readability)

http://www.example.com/joomla17/administrator/components/com_civicrm/civicrm/extern/rest.php
?key=3eaa6a59e42a9286d651c6eb17ddecd5
&api_key=e3a45b104fbb5ff387d471e76acbdd2c
&contact_type=individual
&version=3
&entity=contact
&action=get
&json=1

However, when I tested it against one of the systems that works, I get the following response:

error_message: Unknown function invocation


xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Rest API not responding to queries on some systems
June 18, 2012, 03:36:55 am
Hi,

It does work on 4.1.2 (or will in 4.2) at least, it's the direction we are going and the syntax I want to work properly.

X+

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

simonium

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
Re: Rest API not responding to queries on some systems
June 18, 2012, 03:52:46 am
Thanks Xavier,  I'll do some more testing on it.  I'll post back any progress I make.

simonium

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
Re: Rest API not responding to queries on some systems
June 18, 2012, 07:57:06 am
Hi Xavier,

Yep that worked, the new syntax works for version 4.1.2. It's responding to queries now.  I'm very glad to get that sorted. Thanks again. :)

Simon.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Rest API not responding to queries on some systems

This forum was archived on 2017-11-26.