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) »
  • Autocomplete for Employer
Pages: [1]

Author Topic: Autocomplete for Employer  (Read 1516 times)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Autocomplete for Employer
October 23, 2012, 12:03:44 pm
The Book here http://en.flossmanuals.net/civicrm/ch066_api/ has this code:

Code: [Select]
{if $session->get('userID') > 0}

<script type="text/javascript" src="../{$config->resourceBase}js/rest.js"></script>{literal}
<script>
jQuery(document).ready(function($){
  $('#current_employer').crmAutocomplete({params:{contact_type:'Organization'}});
});
</script>
{/literal}

{/if}

but on my Drupal 7 CiviCRM 4.2.3 site (after I remove ../ from the src value as that is a mistake) it tries to load

/civicrm/ajax/rest?rowCount=35&json=1&entity=Contact&action=quicksearch&sequential=1&params[contact_type]=Organization&s=cs&limit=25&timestamp=1351018925485&name=XXX

and the response is

Code: [Select]
{"IP":"84.229.119.193","level":"security","referer":"","reason":"Destructive HTTP GET","is_error":1,"error_message":
"SECURITY: All requests that modify the database must be http POST, not GET."}

Does anyone know why this is happening?
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Autocomplete for Employer
October 23, 2012, 12:13:35 pm
Damn, our whitelisting was a bit too harsh it seems.

Can you open an issue and assign it to me?

We decided to change the default ajax behaviour so it would use post by default, and would block any action that modify the state of an entity to be a GET (to avoid CSRF and because that's the right thing to do).

I did whitelist only get and getfield, should have added quicksearch too.

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

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Autocomplete for Employer
October 23, 2012, 12:17:11 pm

Issue CRM-11136 - crmAutocomplete Doesn't Work has been successfully created
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Autocomplete for Employer
October 28, 2012, 02:16:26 pm
Fixed
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Autocomplete for Employer
June 27, 2013, 06:33:26 pm
So has the action been changed to getquick?  Does not seem to work with REST.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Autocomplete for Employer
June 27, 2013, 11:10:43 pm
It should. what's the error msg you get?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Autocomplete for Employer
June 28, 2013, 01:24:36 pm
Ok ... here is what is happening - looks like something is broken:

using the API explorer, this works fine:
/civicrm/ajax/rest?entity=Contact&action=getquick&debug=1&sequential=1&json=1&name=test

if I select REST API and add keys (which do authenticate) i get this error:

{
"is_error": 1,
"error_message": "API (,getquick) does not exist (join the API team and implement it!)"
}

If I select REST and use action=quicksearch I get this error:
"level": "security",
"referer": "",
"reason": "Destructive HTTP GET",
"is_error": 1,
"error_message": "SECURITY: All requests that modify the database must be http POST, not GET."
}

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Autocomplete for Employer
June 28, 2013, 03:58:18 pm
What's your url for the rest? seems that entity got lost somewhere
-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) »
  • Autocomplete for Employer

This forum was archived on 2017-11-26.