I tried and seems not working for me either
if applying .encode() to the chinese characters username, or urllib.parse.quote()
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
Failed to create post. Status code: 403
{'errors': ['您没有权限查看请求的资源。API 用户名或者密钥无效。'], 'error_type': 'invalid_access'}
but, without .encode()
headers = {
'Api-Key': API_KEY,
'Api-Username': '大帅哥'
}
I will get error
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256)