Invalid input JSON, Invalid UTF-8 middle byte

SOLVE
Occasional Contributor

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

 

 

# 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)

 

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Solution
Community Manager

Hi @wfong ,

Are you still struggling with this?

 

I found a similar post 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

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!

View solution in original post

Reply
0 Upvotes
2 Replies 2
Solution
Community Manager

Hi @wfong ,

Are you still struggling with this?

 

I found a similar post 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

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!

View solution in original post

Reply
0 Upvotes
Occasional Contributor

Thanks @dennisedson for pointing me in the right direction!

 

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