Best answer

How to remove ctrl-char code 13


Userlevel 1

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?

icon

Best answer by ikbelkirasan 1 July 2020, 14:42

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

12 replies

Userlevel 7
Badge +8

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!

Userlevel 7
Badge +12

@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.

Userlevel 1

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 :

 

Userlevel 7
Badge +12

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

Userlevel 1

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

 

Do you have any pointers?

Userlevel 7
Badge +12

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

Userlevel 1

Hi,

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

 

 

Userlevel 7
Badge +12

@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: "",
},
});
Userlevel 1

@ikbelkirasan 

Thanks for you help!

You mean like this:

 

Userlevel 7
Badge +12

@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:

 

Userlevel 1

@ikbelkirasan 

Thanks! 
It works like a charm now! 

 

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