Answers.Body: <p>This API doesn't exist in CiviCRM but if you want to stick with CiviCRM API (which is better if you want to keep it CMS agnostic), you could create a new CiviCRM API which is not too complex if you are a developer.</p>
  <p>With civix installed, it would require to :</p>
  <ol>
  <li>create an extension `civix generate:module thenewextension</li>
  <li>go in <code>thenewextension</code> and generate the api <code>civix generate:api MyEntity myaction</code></li>
  <li>a new file should be created in <code>api/v3/MyEntity/myaction.php</code></li>
  <li>in the php, call the CMS agnostic function <code>$ufID = CRM_Core_BAO_CMSUser::create($params, $mail);</code> and add the logic you want</li>
  <li>activate the extension</li>
  <li>you should be able to see your api and test it in `https://www.mysite.com/civicrm/api</li>
  </ol>
  <p>To call the API using REST, you need to call the url with the correct parameters (or more likely use a python library that will do much of the work for you) :
  <code>https://www.mysite.com/sites/all/mdoules/civicrm/extern/rest.php?entity=MyEntity&amp;action=myaction&amp;api_key=(myAPIkey)&amp;key=(mySiteKey)&amp;json={“first_name&quot;:&quot;xxx&quot;,&quot;last_name&quot;:&quot;yyy&quot;,&quot;username&quot;:&quot;zzz&quot;}</code></p>
  <ul>
  <li><code>myAPIkey</code> must be created on a contact with the api permission in the database -&gt; civicrm_contact table (or use a handy extension <a href="https://civicrm.org/fr/extensions/api-key" rel="nofollow noreferrer">https://civicrm.org/fr/extensions/api-key</a>)</li>
  <li><code>mySiteKey</code> is in civicrm.settings.php</li>
  <li><code>json</code> contains the parameters of your api call</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-18T15:51:03.113Z
Answers.LastActivityDate: 2021-03-18T15:51:03.113Z
Answers.UserDisplayName: samuelsov
Answers.Body: <p>Since that's straight drupal I would try the <a href="https://www.drupal.org/docs/8/core/modules/rest/1-getting-started-rest-configuration-rest-request-fundamentals" rel="nofollow noreferrer">drupal docs</a> and if you're still stuck you might get more responses at <a href="https://drupal.stackexchange.com">https://drupal.stackexchange.com</a>.</p>
  <p>Another thing you could try but I don't know if it will work is to use civi's api Profile.submit. If you have a profile at admin - customize - profiles which is configured for Drupal User Registration and allows creating users, you might be able to pass in the right parameters to include the account name/email to create the account.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-16T17:50:54.213Z
Answers.LastActivityDate: 2021-03-16T17:50:54.213Z
Answers.UserDisplayName: Demerit
Body: <p>I'm trying to register a new user account to my CiviCRM site and also to create a contact in the CiviCRM system for him. I want to do that via the REST API call application that I'm writing in python.
  After some investigations, I saw that I need to send the request to Drupal system and not to The CiviCRM module.</p>
  <p>Can anyone tell me how can I do that REST API call?</p>
  <p>My CiviCRM is on Bitnami with AWS instance, with Drupal.</p>
  <p>Thanks a lot</p>
  
Tags: <api><civicrm-home><user><rest>
Title: Register new account via REST application
ThreadText: # Register new account via REST application
  
  (Asked by: username_0 on 2021-03-16)
  
  I'm trying to register a new user account to my CiviCRM site and also to create a contact in the CiviCRM system for him. I want to do that via the REST API call application that I'm writing in python.
  After some investigations, I saw that I need to send the request to Drupal system and not to The CiviCRM module.
  
  Can anyone tell me how can I do that REST API call?
  
  My CiviCRM is on Bitnami with AWS instance, with Drupal.
  
  Thanks a lot
  
  **Tags:** api, civicrm-home, user, rest
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-03-18. Score: 0
  
  This API doesn't exist in CiviCRM but if you want to stick with CiviCRM API (which is better if you want to keep it CMS agnostic), you could create a new CiviCRM API which is not too complex if you are a developer.
  
  With civix installed, it would require to :
  
  1. create an extension `civix generate:module thenewextension
  2. go in `thenewextension` and generate the api `civix generate:api MyEntity myaction`
  3. a new file should be created in `api/v3/MyEntity/myaction.php`
  4. in the php, call the CMS agnostic function `$ufID = CRM_Core_BAO_CMSUser::create($params, $mail);` and add the logic you want
  5. activate the extension
  6. you should be able to see your api and test it in `https://www.mysite.com/civicrm/api
  
  To call the API using REST, you need to call the url with the correct parameters (or more likely use a python library that will do much of the work for you) :
  `https://www.mysite.com/sites/all/mdoules/civicrm/extern/rest.php?entity=MyEntity&action=myaction&api_key=(myAPIkey)&key=(mySiteKey)&json={“first_name":"xxx","last_name":"yyy","username":"zzz"}`
  
  * `myAPIkey` must be created on a contact with the api permission in the database -> civicrm\_contact table (or use a handy extension <https://civicrm.org/fr/extensions/api-key>)
  * `mySiteKey` is in civicrm.settings.php
  * `json` contains the parameters of your api call
  
  
  ---
  
  ### Answer by username_2 on 2021-03-16. Score: 0
  
  Since that's straight drupal I would try the [drupal docs](https://www.drupal.org/docs/8/core/modules/rest/1-getting-started-rest-configuration-rest-request-fundamentals) and if you're still stuck you might get more responses at <https://drupal.stackexchange.com>.
  
  Another thing you could try but I don't know if it will work is to use civi's api Profile.submit. If you have a profile at admin - customize - profiles which is configured for Drupal User Registration and allows creating users, you might be able to pass in the right parameters to include the account name/email to create the account.
  
  
  ---
  
  