I spoke too soon, there was one hiccup on the recent upgrade.

I have a bit of custom code on one site that pulls contacts based on 'Primary Address country' as follows (example):

$contactcount=civicrm_api("Contact","getcount", array ('version' =>'3', 'contact_type' =>'Organization', 'country' =>'United States');

When I try this on the API Explorer on the demo site, I get this error:

"error_message":"A fatal error was triggered: United States is not of the type Positive"

API Explorer

It seems to have stopped working with an upgrade from 4.6.7 to 4.6.9. Did something change in the API call?


I was trying to rough in some temporary code to make this functional by using the Country ID instead of the Country Name, and there seems to be a problem there, too. The country ID field in the API seems to be essentially ignored.

$contactcount=civicrm_api("Contact","getcount", array ('version' =>'3', 'contact_type' =>'Organization', 'country_id' => 1228);

I verified this on the demo site, too. I have opened a bug ticket for this.

  • 1
    A PR is submitted as a fix for the ticket mentioned - github.com/civicrm/civicrm-core/pull/6956 Commented Oct 14, 2015 at 9:36
  • @JitendraPurohit If you add this as an answer I will select it.
    – Laryn
    Commented Oct 14, 2015 at 16:50
  • will do that once the PR is merged, seems some optimisation & test fixes need to be done. Thx! Commented Oct 15, 2015 at 5:49

1 Answer 1


This has been fixed at https://github.com/civicrm/civicrm-core/pull/6985 where you can get the Contact using different address fields specifying the names (country, state_province, etc.)

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.