# Invalid input JSON, Invalid UTF-8 middle byte

**URL:** <https://community.hubspot.com/t/invalid-input-json-invalid-utf-8-middle-byte/25886>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [September 23, 2020, 7:03pm UTC](https://community.hubspot.com/t/invalid-input-json-invalid-utf-8-middle-byte/25886 "2020-09-23T19:03:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfong](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wfong/32/68653_2.png) [@wfong](https://community.hubspot.com/u/wfong)\
**Post date:** [September 23, 2020, 7:03pm UTC](https://community.hubspot.com/t/invalid-input-json-invalid-utf-8-middle-byte/25886/1 "2020-09-23T19:03:24Z")

</div>

Hi all,

Here is the response error that I am receiving:

{“status”:“error”,“message”:“Invalid input JSON on line 1, column 39: Invalid UTF-8 middle byte 0x6f”,“correlationId”:“e1c67327-1455-47a4-a525-ef136721f550”}

I copied the sample python API code for searching the contact objects. When I tried to run the same code in my Python file, it fails. It seems to work only with non-accented text strings, but strings with characters such as “ñ” and “Ê” cause it to fail. Am I missing something to make it work with accented characters?

Thank for the help!

Wayde

```lia-code-sample
# Sample code from the Hubspot API pages
# Search Contacts

import requests

url = "https://api.hubapi.com/crm/v3/objects/contacts/search"

querystring = {"hapikey":"XXXXXXXXXXXXXXXXXXXXXXXX"}

payload = "{\"filterGroups\":[{\"filters\":[{\"value\":\"Baño\",\"propertyName\":\"firstname\",\"operator\":\"EQ\"}]}],\"sorts\":[\"string\"],\"query\":\"string\",\"properties\":[\"string\"],\"limit\":0,\"after\":0}"
headers = {
 'accept': "application/json",
 'content-type': "application/json"
 }

response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

print(response.text)

```

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [September 25, 2020, 3:52pm UTC](https://community.hubspot.com/t/invalid-input-json-invalid-utf-8-middle-byte/25886/2 "2020-09-25T15:52:26Z")

</div>

Hi @wfong ,

Are you still struggling with this?

I found a [similar post](https://community.hubspot.com/t5/APIs-Integrations/Python-create-Contact-with-umlauts/m-p/272204) involving umlauts that @akaiser both asked and resolved that may be of value to you.

@akaiser , @dornan1 , do you have thoughts on this?

Thanks!

d

---

<div class="post-metadata">

**Author:** ![wfong](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wfong/32/68653_2.png) [@wfong](https://community.hubspot.com/u/wfong)\
**Post date:** [September 25, 2020, 4:22pm UTC](https://community.hubspot.com/t/invalid-input-json-invalid-utf-8-middle-byte/25886/3 "2020-09-25T16:22:41Z")

</div>

Thanks @dennisedson for pointing me in the right direction!

Using @akaiser’s solution worked so thanks to him too!

---

<div class="post-metadata">

**Author:** ![MBurns](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mburns/32/102498_2.png) [@MBurns](https://community.hubspot.com/u/MBurns)\
**Post date:** [January 26, 2021, 10:52pm UTC](https://community.hubspot.com/t/invalid-input-json-invalid-utf-8-middle-byte/25886/4 "2021-01-26T22:52:12Z")

</div>

For future googlers… I had this same problem, it’s when your request isn’t encoded in UTF-8.

ps. if you’re using java, the default Charset depends on your JVM. On macOS it’s UTF-8 but on appengine for example, it’s US\_ASCII. Therefore, don’t rely on default, always choose the encoding. eg:

`new StringEntity("café", StandardCharsets.UTF_8)`

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [January 27, 2021, 5:22pm UTC](https://community.hubspot.com/t/invalid-input-json-invalid-utf-8-middle-byte/25886/5 "2021-01-27T17:22:01Z")

</div>

Thank you for adding your solution here, @MBurns !
