Answers.Body: <p>Did you use api4 explorer (http://{site}/civicrm/api4) to generate that? You probably mean <code>values</code> instead of <code>where</code>.</p>
  <p>And to do Email you'll need to chain: <a href="https://docs.civicrm.org/dev/en/latest/api/v4/chaining/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/api/v4/chaining/</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-17T08:05:50.467Z
Answers.Text: No, I'm created it by myself, When I try to follow this link it goes to 404 (http://{site}/civicrm/api4) and (http://{site}/wp-admin/civicrm/api4). 
  
  Where I can see the name of the fields and everything connected with them, such as e-mail chaining?
Answers.UserDisplayName: Rustam
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-17T08:10:24.357Z
Answers.Text: And when I replace "where" to "values" and drop the "email", returns all the same 500. $result = civicrm_api4('Contact', 'Create', [
          'values' => [
              ['first_name', '=', $_POST['first-name']],
              ['last_name', '=', $_POST['last-name']],
            ],
          ]);
Answers.UserDisplayName: Rustam
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-17T09:14:22.330Z
Answers.Text: I found worked URL - {my_site}/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fapi4#/explorer/Contact/
Answers.UserDisplayName: Rustam
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-16T15:00:41.817Z
Answers.LastActivityDate: 2021-06-16T15:00:41.817Z
Answers.UserDisplayName: Demerit
Body: <p>Whats wrong with this code?
  After submitting my form, I want to create a new contact in CRM via PHP, but it returned 500</p>
  <pre><code>$result = civicrm_api4('Contact', 'Create', [
      'where' =&gt; [
          ['first_name', '=', $_POST['first-name']],
          ['last_name', '=', $_POST['last-name']],
          ['email', '=', $_POST['email']],
        ]
      ]);
  </code></pre>
  
Tags: <api>
Title: Create Contact from PHP
ThreadText: # Create Contact from PHP
  
  (Asked by: username_0 on 2021-06-16)
  
  Whats wrong with this code?
  After submitting my form, I want to create a new contact in CRM via PHP, but it returned 500
  $result = civicrm_api4('Contact', 'Create', [
      'where' => [
          ['first_name', '=', $_POST['first-name']],
          ['last_name', '=', $_POST['last-name']],
          ['email', '=', $_POST['email']],
        ]
      ]);
  
  **Tags:** api
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-16. Score: 0 | Accepted answer
  
  Did you use api4 explorer (http://{site}/civicrm/api4) to generate that? You probably mean `values` instead of `where`.
  
  And to do Email you'll need to chain: <https://docs.civicrm.org/dev/en/latest/api/v4/chaining/>
  
  > **Comments:**
  > **username_0**: No, I'm created it by myself, When I try to follow this link it goes to 404 (http://{site}/civicrm/api4) and (http://{site}/wp-admin/civicrm/api4).   Where I can see the name of the fields and everything connected with them, such as e-mail chaining?  
  > **username_0**: And when I replace "where" to "values" and drop the "email", returns all the same 500. $result = civicrm_api4('Contact', 'Create', [         'values' => [             ['first_name', '=', $_POST['first-name']],             ['last_name', '=', $_POST['last-name']],           ],         ]);  
  > **username_0**: I found worked URL - {my_site}/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fapi4#/explorer/Contact/  
  
  ---
  
  