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 Authentication Issues
Pages: [1]

Author Topic: REST API Authentication Issues  (Read 608 times)

dtheweather9

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 1
    • Students for the Exploration and Development of Space, USA
  • CiviCRM version: 4.4.0
  • CMS version: WordPress 3.8.1
  • MySQL version: 5.1.56
  • PHP version: 5.4.11
REST API Authentication Issues
July 12, 2013, 02:05:54 pm
Greetings,
After deciphering the method to create a rest api_key on a given users, I've run into an issue.

When sending a rest for a valid contact (using this string) when not logged in,

[siteroot]/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=get&debug=1&sequential=1&json=1&contact_id=5305key=[Valid Key]&api_key=[Valid API Key]

I get a result with a response of:

Code: [Select]
{
"is_error":0,
"undefined_fields":["civicrm_install_type","id"],
"version":3,
"count":0,
"values":[]
}

undefined_fields only shows up on the field;

When logged in as the api user, then the REST query properly gives the contact information expected, though still has the error of the 'civicrm_install_type'.  As the data is there its fine.

When putting in an 'id' field, the response is then :
Code: [Select]
"undefined_fields":["contact_id","id","civicrm_install_type"],
I've setup the user with full admin both on wordpress and on civicrm, and that still has not resolved the issue.

Is there something wrong setup in authentication that I've missed?  Should the api key for the user be provisioned somewhere else than the contact table in order for them to have access to the api?

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 Authentication Issues
July 12, 2013, 11:42:50 pm
Hi,

Seems to be an error in the undefined_fields, but it's a notice only, you can ignore for now.

I would not send the keys in a get url (so they don't end up in the log and so on), if your consumer is php, you can try copy api/class.api.php that takes care of wrapping that (read the source, they are examples on how to use it at the top).

Can you as well try using id instead of contact_id (I doubt it makes a difference, but that's the "more right" way)

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • REST API Authentication Issues

This forum was archived on 2017-11-26.