Answers.Body: <p>What you are asking is "How do I send a POST request with PHP?". See the following stackoverflow question: <a href="https://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php">https://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php</a> .</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-17T08:08:09.497Z
Answers.Text: Thank Kainuk, in Itaky we says "I was lost in a glass of water"
Answers.UserDisplayName: marcello
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-16T18:15:51.533Z
Answers.LastActivityDate: 2016-11-16T18:15:51.533Z
Answers.LastEditDate: 2017-05-23T12:38:59.763Z
Answers.UserDisplayName: Kainuk - CiviCooP
Body: <p>I have the need to create/update a contact from an external site.
  If I understand correctly, the only way to do this is to use Rest API. In my test I had no problem to read the database, but when using the "create" action, as in the following PHP code:</p>
  
  <blockquote>
    <p>$url='<a href="http://.../sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=create&amp;api_key=...&amp;key=...&amp;json=" rel="nofollow noreferrer">http://.../sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=create&amp;api_key=...&amp;key=...&amp;json=</a>{"sequential":1,"first_name":"Gianni","last_name":"Predan"}';</p>
    
    <p>$responsestr = file_get_contents($url);</p>
  </blockquote>
  
  <p>I obtain the error "<em>All requests that modify the database must be http POST, not GET.</em>"</p>
  
  <p>What should I do?
  Thanks</p>
  
Tags: <api><rest>
Title: API - Create a contact from an external site
ThreadText: # API - Create a contact from an external site
  
  (Asked by: username_0 on 2016-11-16)
  
  I have the need to create/update a contact from an external site.
  If I understand correctly, the only way to do this is to use Rest API. In my test I had no problem to read the database, but when using the "create" action, as in the following PHP code:
  
  > $url='<http://.../sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=create&api_key=...&key=...&json=>{"sequential":1,"first\_name":"Gianni","last\_name":"Predan"}';
  >
  > $responsestr = file\_get\_contents($url);
  
  I obtain the error "*All requests that modify the database must be http POST, not GET.*"
  
  What should I do?
  Thanks
  
  **Tags:** api, rest
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-11-16. Score: 2 | Accepted answer
  
  What you are asking is "How do I send a POST request with PHP?". See the following stackoverflow question: <https://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php> .
  
  > **Comments:**
  > **username_0**: Thank username_1, in Itaky we says "I was lost in a glass of water"  
  
  ---
  
  