Skip to main content

Hi everyone,

 

I have an issue to make an post api call to HubSpot. The value that i want to send gives this

Invalid input JSON on line 16, column 17: Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value

Does anyone have any idea or tips or scripts to remove all these?

Hi there @rikmaris - I’ve gone ahead and escalated your question to our Support team. Please respond to the ticket to let us know the requested information. Thanks!


@rikmaris - Can you show the JSON payload you’re sending as a POST request? This is more likely to be a syntax error in the JSON which rendered it invalid.


Hi there,

 

What i am doing is a body of an e-mail, sent to a gmail g suite account, sending as a POST request. The error also occured when i testing it with POSTMAN app. 

The payload is:

Lieke heeft het volgende bericht voor u genoteerd
Gebeld door : Dominique om
Ref. :
Organisatie :
Telefoon vast : 0000
Telefoon mobiel :
E-mail :

 


@rikmaris - That payload is not a valid JSON so that’s why you’re getting the error.


I know, that is not right json. But i don't know how to fix this. 

 

Do you have any pointers?


@rikmaris Ok, can you show a screenshot of how the webhook step is set up?


Hi,

i just add the text from an e-mail to a post request. 

 

 


@rikmaris - Try building the data object in a JavaScript code step instead. The code snippet below expects you to assign the email subject to an input variable called subject. The output will be a valid JSON that you can use in the subsequent webhook step.

const toJSON = (o) => JSON.stringify(o, null, 2);
const { subject } = inputData;

output = toJSON({
properties: {
hs_pipeline: "xxx",
hs_pipeline_stage: "xxx",
hs_ticket_category: "Callback request",
hs_ticket_priority: "HIGH",
subject: `TITEL AANPASSEN ${subject}`,
content: "",
},
});

@ikbelkirasan 

Thanks for you help!

You mean like this:

 


@rikmaris - Well, not quite. You have to create a Code by Zapier step before the webhook step to prepare the data payload.

 

Then, paste this code snippet in the Code field and add subject as an input field:

const toJSON = (o) => JSON.stringify(o, null, 2);
const { subject } = inputData;

output =
{
data: toJSON({
properties: {
hs_pipeline: "xxx",
hs_pipeline_stage: "xxx",
hs_ticket_category: "Callback request",
hs_ticket_priority: "HIGH",
subject: `TITEL AANPASSEN ${subject}`,
content: "",
},
}),
},
];

 

Finally, back to the webhook step: you should map the code step output to the Data field, like this:

 


@ikbelkirasan 

Thanks! 
It works like a charm now! 

 

Is there any way to adjust this and that all enters are there in the output?