API - Foreign Languages

Hi,
Whenever we try to Create/Update a contact using the API to a contact whois name/last name is in foreign language, we get a 400 Bad Request error.

How should we encode that? or deal with the issue?

I try with UTF8Encoding C#

Example: Villalón

Thanks!

Hey @rarayav,

It doesn’t appear that HubSpot does encoding on our end. I made a simple POST request to this [endpoint](http://Create%20a new contact | Contacts API)

POST https://api.hubspot.com/contacts/v1/contact?hapikey={{my hapikey}}

with the following POST body

and I’m able to see the contact name shows up just fine:

Could it be that the problem is the api version I am using?
My code:

string url = “https://api.hubapi.com/crm/v3/objects/contacts?hapikey={MyApiKey}”;
WebRequest myReq = WebRequest.Create(url);
myReq.Method = “POST”;
myReq.ContentType = “application/json; charset=utf-8”;
string data = “{\“properties\”:{ \“lastname\”: \“Villalón\” } }”;

When I remove the accent mark it works, but that doesn’t work for me

Hey @rarayav,

I tried using the v3 endpoint

POST crm/v3/objects/contacts?hapikey={{myhapikey}}

{
 "properties": {
 "lastname": "Villalón",
"firstname": "18test"
 }
}

and I’m seeing that a contact with the last name Villalón was created successfully:

Could you try removing the encoding charset=utf-8?

the following worked

(C#)

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(“https://api.hubapi.com/crm/v3/objects/contacts?hapikey=XXXXXX”);
request.Method = “POST”;
request.Accept = “application/json”;
request.ContentType = “application/json”;

using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
string data = "{\“properties\”: {\“lastname\”: \“Villalón\”,\“firstname\”: \“19test\”, \“hubspot_owner_id\”: \“47664540\”}} ";

streamWriter.Write(data);
}

var response = request.GetResponse();
string text;

using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
return text;

thank you very much for your help