Answers.Body: <p>This has been fixed at <a href="https://github.com/civicrm/civicrm-core/pull/6985" rel="nofollow">https://github.com/civicrm/civicrm-core/pull/6985</a> where you can get the Contact using different address fields specifying the names (country, state_province, etc.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-16T12:50:05.170Z
Answers.LastActivityDate: 2015-10-16T12:50:05.170Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>I <a href="https://twitter.com/kragtbakker/status/652185995505475584" rel="nofollow noreferrer">spoke too soon</a>, there was one hiccup on the recent upgrade.</p>
  
  <p>I have a bit of custom code on one site that pulls contacts based on 'Primary Address country' as follows (example):</p>
  
  <p><code>$contactcount=civicrm_api("Contact","getcount", array ('version' =&gt;'3', 'contact_type' =&gt;'Organization', 'country' =&gt;'United States');</code></p>
  
  <p>When I try this on the API Explorer on the demo site, I get this error:</p>
  
  <p><code>"error_message":"A fatal error was triggered: United States is not of the type Positive"</code></p>
  
  <p><a href="https://i.sstatic.net/gcuTv.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gcuTv.jpg" alt="API Explorer"></a></p>
  
  <p>It seems to have stopped working with an upgrade from 4.6.7 to 4.6.9. Did something change in the API call?</p>
  
  <p>Update:</p>
  
  <p>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.</p>
  
  <p><code>$contactcount=civicrm_api("Contact","getcount", array ('version' =&gt;'3', 'contact_type' =&gt;'Organization', 'country_id' =&gt; 1228);</code></p>
  
  <p>I verified this on the demo site, too. I have <a href="https://issues.civicrm.org/jira/browse/CRM-17361" rel="nofollow noreferrer">opened a bug ticket for this</a>.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-14T09:36:15.707Z
Comments.Text: A PR is submitted as a fix for the ticket mentioned - https://github.com/civicrm/civicrm-core/pull/6956
Comments.UserDisplayName: jitendra - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-14T16:50:41.620Z
Comments.Text: @JitendraPurohit If you add this as an answer I will select it.
Comments.UserDisplayName: Laryn
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-15T05:49:13.670Z
Comments.Text: will do that once the PR is merged, seems some optimisation & test fixes need to be done. Thx!
Comments.UserDisplayName: jitendra - fuzion
Tags: <api><upgrade>
Title: API: Contact get/getcount by primary address country stopped working on upgrade to 4.6.9
ThreadText: # API: Contact get/getcount by primary address country stopped working on upgrade to 4.6.9
  
  (Asked by: username_0 on 2015-10-09)
  
  I [spoke too soon](https://twitter.com/kragtbakker/status/652185995505475584), 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](https://i.sstatic.net/gcuTv.jpg)](https://i.sstatic.net/gcuTv.jpg)
  
  It seems to have stopped working with an upgrade from 4.6.7 to 4.6.9. Did something change in the API call?
  
  Update:
  
  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](https://issues.civicrm.org/jira/browse/CRM-17361).
  
  **Tags:** api, upgrade
  
  > **Comments:**
  > **username_1**: A PR is submitted as a fix for the ticket mentioned - https://github.com/civicrm/civicrm-core/pull/6956  
  > **username_0**: @JitendraPurohit If you add this as an answer I will select it.  
  > **username_1**: will do that once the PR is merged, seems some optimisation & test fixes need to be done. Thx!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-10-16. Score: 1 | Accepted answer
  
  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.)
  
  
  ---
  
  