Answers.Body: <p>I just installed a CiviCRM and Drupal 9 instance (5.40.1). These were my steps:</p>
  <ul>
  <li>I enabled the new authx extension <code>cv ext:enable authx</code></li>
  <li>I allowed the authenticate with the api_key in a special header <code>cv ev 'Civi::settings()-&gt;set(&quot;authx_xheader_cred&quot;,[&quot;api_key&quot;]);'</code> The auth extension does not have a configuration screen, yet.</li>
  <li>I added site key as an extra protection <code>cv ev 'Civi::settings()-&gt;set(&quot;authx_guards&quot;,[&quot;site_key&quot;]);'</code>.</li>
  <li>I flushed the CiviCRM cache <code>cv flush</code></li>
  </ul>
  <p>And now the following CURL command can be used to call the REST api:</p>
  <pre><code>curl -X GET --location &quot;http://&lt;&lt;server&gt;&gt;/civicrm/ajax/rest? 
  entity=Contact&amp;action=get&amp;json=1&quot; \
  -H &quot;X-Civi-Auth: Bearer &lt;&lt;api_key&gt;&gt;&quot; \
  -H &quot;X-Civi-Key: &lt;&lt;site_key&gt;&gt;&quot; \
  -H &quot;Accept: application/json&quot; \
  -H &quot;X-Requested-With: XMLHttpRequest&quot;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-09T10:39:55.793Z
Answers.LastActivityDate: 2021-08-09T10:52:00.793Z
Answers.LastEditDate: 2021-08-09T10:52:00.793Z
Answers.UserDisplayName: Kainuk - CiviCooP
Answers.Body: <p>My previous answer here is now out dated.  Now the endpoint is <code>/civicrm/ajax/rest</code>.  But first you must enable the AuthX extension (<strong>Administer menu » System Settings » Extensions</strong>).  Then you'll have an Authentication menu at <strong>Administer menu » System Settings » Authentication</strong>.  There is a link to documentation from there that provides instructions for more complex workflows.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-05T17:03:58.403Z
Answers.Text: I used a symbolic link to ```<drupal root>/vendor/civicrm/civicrm-core/extern``` in ```<drupal root>/web/libraries/civicrm/core``` since that will, I hope, make sure that the folder remains in date. 
  
  i
Answers.UserDisplayName: Stephen Palmstrom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-17T17:20:40.640Z
Answers.LastActivityDate: 2022-09-14T12:10:42.593Z
Answers.LastEditDate: 2022-09-14T12:10:42.593Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I know there's been a lot of work to deprecate the <code>extern</code> endpoints in CiviCRM, and the <code>extern</code> endpoints don't work in Drupal 8 without a lot of finagling.  The documentation isn't updated to reflect a new way of using D8 REST endpoints, nor is API Explorer.  Does anyone know what the &quot;correct&quot; endpoint is?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-11T18:51:40.027Z
Comments.Text: I think this is still in flux so need to add the word "today" on the end of the question (grin). See also https://lab.civicrm.org/dev/core/-/issues/2077 and https://github.com/civicrm/civicrm-core/pull/17952
Comments.UserDisplayName: Demerit
Tags: <api><drupal-8><rest>
Title: What is the correct REST URL in Drupal 8 (or 9)?
ThreadText: # What is the correct REST URL in Drupal 8 (or 9)?
  
  (Asked by: username_0 on 2020-10-11)
  
  I know there's been a lot of work to deprecate the `extern` endpoints in CiviCRM, and the `extern` endpoints don't work in Drupal 8 without a lot of finagling. The documentation isn't updated to reflect a new way of using D8 REST endpoints, nor is API Explorer. Does anyone know what the "correct" endpoint is?
  
  **Tags:** api, drupal-8, rest
  
  > **Comments:**
  > **username_1**: I think this is still in flux so need to add the word "today" on the end of the question (grin). See also https://lab.civicrm.org/dev/core/-/issues/2077 and https://github.com/civicrm/civicrm-core/pull/17952  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2021-08-09. Score: 3
  
  I just installed a CiviCRM and Drupal 9 instance (5.40.1). These were my steps:
  
  * I enabled the new authx extension `cv ext:enable authx`
  * I allowed the authenticate with the api\_key in a special header `cv ev 'Civi::settings()->set("authx_xheader_cred",["api_key"]);'` The auth extension does not have a configuration screen, yet.
  * I added site key as an extra protection `cv ev 'Civi::settings()->set("authx_guards",["site_key"]);'`.
  * I flushed the CiviCRM cache `cv flush`
  
  And now the following CURL command can be used to call the REST api:
  
  ```
  curl -X GET --location "http://<<server>>/civicrm/ajax/rest? 
  entity=Contact&action=get&json=1" \
  -H "X-Civi-Auth: Bearer <<api_key>>" \
  -H "X-Civi-Key: <<site_key>>" \
  -H "Accept: application/json" \
  -H "X-Requested-With: XMLHttpRequest"
  
  ```
  
  
  ---
  
  ### Answer by username_0 on 2020-10-17. Score: 3
  
  My previous answer here is now out dated. Now the endpoint is `/civicrm/ajax/rest`. But first you must enable the AuthX extension (**Administer menu » System Settings » Extensions**). Then you'll have an Authentication menu at **Administer menu » System Settings » Authentication**. There is a link to documentation from there that provides instructions for more complex workflows.
  
  > **Comments:**
  > **username_3**: I used a symbolic link to ```<drupal root>/vendor/civicrm/civicrm-core/extern``` in ```<drupal root>/web/libraries/civicrm/core``` since that will, I hope, make sure that the folder remains in date.   i  
  
  ---
  
  