Invalid JSON Input



I am constantly receiving errors from the "new event" API due to accented or special characters (most of them spanish accents and punctuation) that are present in the event extraData field.

I would like to know why these characters cause errors?
Is there any setting for my app that could accept accented characters and punctuation marks in the JSON object?

Best regards

Douglas Acosta

Here is a sample error messaje

Invoke-WebRequest : {"status":"error","message":"Invalid input JSON on line 1, column 440: Invalid UTF-8 middle byte 0x61\n at [Source:; line: 1, column:
At E:\BI\PROJECTS\SSIS\MT_DW\MT_DW\EC_LiveChatToHubspot.ps1:211 char:13
+             Invoke-WebRequest -uri $url -Body $new_event -Headers $he ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand


Hi @Douglas, happy to help here! Are you using the Timeline API here: to make your requests? If so, can I see an example body for a PUT request that you're making with the endpoint? I'll be able to clarify with my team which characters are supported, but if it's included in the UTF-8 character set, then it should be okay I believe.


Hi Connor

I am encoding each string as UTF-8 but keep receiving error messages when accented characters are present.

Here is a sample event I am sending, notice the "ú" character

{"id":"P8KQIHYOTW-1","email":"","eventTypeId":"382537","MT_ChatID":"P8KQIHYOTW-1","extraData":{"urlinicio":"","fecha":"14/05/2018","chatLines":[{"autor":"Carmen Elena Velasco","hora":"14:51","mensaje":"Hello, would you like to talk about our products?"},{"autor":"Paúl","hora":"....

By now I am replacing all of these characters with another character but it is not the ideal solution. Do you think we can work this out? what else would you need to identify the error.

The environment I am using is:
The data comes from a SQLServer 2017 (collation SQL_Latin1_General_CP1_CI_AS, codepage 1252, locale 1033)

I am using powershell as my interface to call Hubspot APIs
using powershell I am stripping all control characters
$ControlCharacters = "r|n|`t|\"

and I am translating the data from sqlserver *codepage 1252 to UTF-8"

UPDATE: I tried with different code pages: 65001 (unicode) also


Hi @Douglas, thanks for that extra info, very helpful. I was just looking more for a raw request to HubSpot that you're making so that I can try to reproduce the issue, but your response above should suffice. Can you reply with your App ID, and the HubID to the portal where this request is failing?


Hi Connor, sure the app id is 184462 and I think the portal id is this 4187609 (not quite sure)


Cool no worries, i'll take a look through the logs of the app to see which requests are failing so don't worry about the portal id. I'll reach back out when I have more info!