# Unicode usernames

**URL:** <https://meta.discourse.org/t/unicode-usernames/277878>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [September 5, 2023, 4:50pm UTC](https://meta.discourse.org/t/unicode-usernames/277878 "2023-09-05T16:50:44Z")\
**Posts on this page:** 1\
**Showing post:** 29

<div class="post-metadata">

**Author:** ![xFocus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xfocus/32/463960_2.png) [@xFocus](https://meta.discourse.org/u/xFocus)\
**Post date:** [November 28, 2024, 3:13pm UTC](https://meta.discourse.org/t/unicode-usernames/277878/29 "2024-11-28T15:13:49Z")

</div>

I tried and seems not working for me either

if applying `.encode()` to the chinese characters username, or `urllib.parse.quote()`

```plaintext
    headers = {
        'Api-Key': API_KEY,
        'Api-Username': '大帅哥'.encode()
    }

    # or urllib parse
    headers = {
        'Api-Key': API_KEY,
        'Api-Username': urllib.parse.quote(API_USERNAME)
    }

```

I will get error

```plaintext
Failed to create post. Status code: 403
{'errors': ['您没有权限查看请求的资源。API 用户名或者密钥无效。'], 'error_type': 'invalid_access'}

```

but, without `.encode()`

```plaintext
    headers = {
        'Api-Key': API_KEY,
        'Api-Username': '大帅哥'
    }

```

I will get error

```plaintext
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256)

```

---

_[View the full topic](https://meta.discourse.org/t/unicode-usernames/277878)._
