Question marks instead of Cyrillic?


#1

I’m created a company using API, but when I send Cyrillic symbols in company name or description, it’s replace on question marks.

    HubSpotCompanyDto companyName = new HubSpotCompanyDto();
    companyName.setName("name");
    companyName.setValue("Имя ком");
    HubSpotCompanyDto companyDescription = new HubSpotCompanyDto();
    companyDescription.setName("description");
    companyDescription.setValue("");
    String postUrl = "https://api.hubapi.com/companies/v2/companies?hapikey=" + API_KEY;
    Gson gson = new Gson();
    HttpClient httpClient = HttpClientBuilder.create().build();
    HttpPost post = new HttpPost(postUrl);
    HubSpotCompanyPropertiesDto properties = new HubSpotCompanyPropertiesDto();
    properties.setProperties(Arrays.asList(companyName, companyDescription));
    StringEntity postingString = new StringEntity(gson.toJson(properties));
    post.setEntity(postingString);
    post.setHeader("Content-type", "application/json");
    HttpResponse response = httpClient.execute(post);

company name in hubspot interface is ??? ???


#2

Hi @Vlad,

Is the encoding set to UTF-8? I tested this request out and was able to successfully create a company with the name ‘Имя ком’


#3

Yes, in my project encoding set to UTF-8, and I try
post.setHeader(“Content-type”, “application/json; charset=UTF-8”);
Does not help, still question marks.


#4

Hi @Vlad,

While I’m not entirely familiar with your code (looks to be Java?) it looks like you might have to include the encoding in the parameters of your new StringEntity, like this:

StringEntity example = new StringEntity(data,"UTF-8"); 

You can see this format being used in the following examples. Can you try adding the encoding as a StringEntity parameter to see if that works?


#5

Hi @Derek_Gervais,

Yes, Java. Thank you, it works )