# Check\_username api endpoint seems to not work correctly

**URL:** https://meta.discourse.org/t/check-username-api-endpoint-seems-to-not-work-correctly/81656
**Category:** Support
**Created:** [February 27, 2018, 12:52pm UTC](https://meta.discourse.org/t/check-username-api-endpoint-seems-to-not-work-correctly/81656 "2018-02-27T12:52:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![parisa](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@parisa](https://meta.discourse.org/u/parisa)
#### Post date: [February 27, 2018, 12:52pm UTC](https://meta.discourse.org/t/check-username-api-endpoint-seems-to-not-work-correctly/81656/1 "2018-02-27T12:52:04Z")

</div>

when we want to sinup in discourse and write a username, if the username is taken, discourse suggest for another username. I wanted to use this feature in my apis and tracked down the api call made by discourse using [this topic](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576).

It seems I should do somthing like the following, however when I test it with postman, I dont get the correct response:

`https://myforum.com/u/check_username?api_key=xxxx&api_username=yyyy&username=zzzz&email=a@b.c`

This is also the php code I wrote for this:

```plaintext
$discourse_url = 'https://myforum.com/';
$api_user = 'xxxx';
$api_key = 'yyyy';
$username = 'zzz';
$email = 'a@b.c'
$data = array( 'api_key'=>$api_key, 'api_username'=>$api_user, 'username'=>$username, 'email'=>$email);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $discourse_url."u/check_username?".http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
$response = curl_exec($ch);
echo $response;

```

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [February 27, 2018, 4:21pm UTC](https://meta.discourse.org/t/check-username-api-endpoint-seems-to-not-work-correctly/81656/2 "2018-02-27T16:21:08Z")

</div>

Try appending `.json` to your url and it should work.

`https://myforum.com/u/check_username.json?api_key=xxxx&api_username=yyyy&username=zzzz&email=a@b.c`

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/e/9e61c418d76fef3355c532186895dfb4a5d4fe75.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:37pm UTC](https://meta.discourse.org/t/check-username-api-endpoint-seems-to-not-work-correctly/81656/3 "2024-06-08T12:37:45Z")

</div>

This topic was automatically closed after 2292 days. New replies are no longer allowed.
