I'm trying to use the Python Civicrm API located here: https://github.com/tallus/python-civicrm . I can connect to the site just fine, but anytime I try to query any of the content I get a 404 Error from the /extern/rest.php.

I am using an Admin account that has an API key.

from pythoncivicrm.pythoncivicrm import CiviCRM

url = 'http://sitename.org'  # works
site_key ='642346924242934720'  # works
api_key ='dbJKbjkse903332'  # works
civicrm = CiviCRM(url, site_key, api_key) # works

search_results = civicrm.get('Contacts') # ERROR

pythoncivicrm.pythoncivicrm.CivicrmError: request to https://sitename.org/extern/rest.php failed with status code 404

If I'm already admin, what other possible reason could it be that I'm still getting blocked?

Thank you!

  • 1
    That url looks wrong - for a drupal site it would normally be sitename.org/sites/all/modules/civicrm/extern/rest.php (ie a full path to the file not one mediated via the CMS)
    – user4278
    Commented Jul 13, 2018 at 2:08
  • Ah! You were right! The second I replaced the URL with that you suggested I was able to return the data. Thanks so much! Commented Jul 14, 2018 at 20:09

2 Answers 2


The URL was wrong like, @user4278 suggested. It should have been: sitename.org/sites/all/modules/civicrm/extern/rest.php


Why do you use the Python library? You can just call the URL directly with the library request. If you want to get the correct URL you can fo to the page http://domain.tld/civicrm/api#explorer and chose an action, once you chose one, you get the full URL of the request. You'll have to make some changes to the URL tho, you have to replace the site_key and the api_key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.