Answers.Body: <p>Try upgrading to 5.13.2 since there is lots of change in dedupe rule code since 5.6.</p>
  
  <p>Cheers</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-09T19:15:23.867Z
Answers.Text: Hate to ask, but any options outside of upgrading? Upgrading is going to take a while in our situation. It's just odd that it just started happening.
Answers.UserDisplayName: Paul B
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-09T16:40:40.143Z
Answers.LastActivityDate: 2019-05-09T16:40:40.143Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>On version 5.6.0, using api v3. Not sure if something recently changed in our environment, but as of a couple of days ago, running the contact create api (via rest or the explorer) causes a "DB Error: no database selected" error when using the "dupe_check" parameter.</p>
  
  <p>For example, if I run this call, the contact is created and api returns successfully:</p>
  
  <pre><code>https://domain.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=create&amp;api_key=userkey&amp;key=sitekey&amp;json={"contact_type":"Individual","first_name":"pol","last_name":"vor","email":"povor@gmail.com"}
  </code></pre>
  
  <p>But if I run this call, which just has "dupe_check:1" added to it, it fails:</p>
  
  <pre><code>https://domain.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=create&amp;api_key=userkey&amp;key=sitekey&amp;json={"contact_type":"Individual","first_name":"pol","last_name":"vor","email":"povor@gmail.com","dupe_check":1}
  </code></pre>
  
  <p>The error details are as follows (from the API Explorer, but it's the same running from a script):</p>
  
  <pre><code>    {
      "code": -14,
      "error_message": "DB Error: no database selected",
      "mode": 16,
      "debug_info": "DROP TEMPORARY TABLE IF EXISTS dedupe [nativecode=2006 ** MySQL server has gone away]",
      "type": "DB_Error",
      "user_info": "DROP TEMPORARY TABLE IF EXISTS dedupe [nativecode=2006 ** MySQL server has gone away]",
      "to_string": "[db_error: message=\"DB Error: no database selected\" code=-14 mode=callback callback=CRM_Utils_REST::fatal prefix=\"\" info=\"DROP TEMPORARY TABLE IF EXISTS dedupe [nativecode=2006 ** MySQL server has gone away]\"]",
      "is_error": 1
  }
  </code></pre>
  
  <p>Any ideas on what may be causing this? I have a workaround in production for now, but this is a really useful feature to have in the API.</p>
  
Tags: <api><duplicate-contacts>
Title: DB Error when using dupe_check in rest API
ThreadText: # DB Error when using dupe_check in rest API
  
  (Asked by: username_0 on 2019-05-09)
  
  On version 5.6.0, using api v3. Not sure if something recently changed in our environment, but as of a couple of days ago, running the contact create api (via rest or the explorer) causes a "DB Error: no database selected" error when using the "dupe\_check" parameter.
  
  For example, if I run this call, the contact is created and api returns successfully:
  
  ```
  https://domain.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=create&api_key=userkey&key=sitekey&json={"contact_type":"Individual","first_name":"pol","last_name":"vor","email":"povor@gmail.com"}
  
  ```
  
  But if I run this call, which just has "dupe\_check:1" added to it, it fails:
  
  ```
  https://domain.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=create&api_key=userkey&key=sitekey&json={"contact_type":"Individual","first_name":"pol","last_name":"vor","email":"povor@gmail.com","dupe_check":1}
  
  ```
  
  The error details are as follows (from the API Explorer, but it's the same running from a script):
  
  ```
      {
      "code": -14,
      "error_message": "DB Error: no database selected",
      "mode": 16,
      "debug_info": "DROP TEMPORARY TABLE IF EXISTS dedupe [nativecode=2006 ** MySQL server has gone away]",
      "type": "DB_Error",
      "user_info": "DROP TEMPORARY TABLE IF EXISTS dedupe [nativecode=2006 ** MySQL server has gone away]",
      "to_string": "[db_error: message=\"DB Error: no database selected\" code=-14 mode=callback callback=CRM_Utils_REST::fatal prefix=\"\" info=\"DROP TEMPORARY TABLE IF EXISTS dedupe [nativecode=2006 ** MySQL server has gone away]\"]",
      "is_error": 1
  }
  
  ```
  
  Any ideas on what may be causing this? I have a workaround in production for now, but this is a really useful feature to have in the API.
  
  **Tags:** api, duplicate-contacts
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-05-09. Score: 1 | Accepted answer
  
  Try upgrading to 5.13.2 since there is lots of change in dedupe rule code since 5.6.
  
  Cheers
  
  username_1
  
  > **Comments:**
  > **username_0**: Hate to ask, but any options outside of upgrading? Upgrading is going to take a while in our situation. It's just odd that it just started happening.  
  
  ---
  
  