Skip to main content
Best answer

How to remove ctrl-char code 13


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?

Best answer by ikbelkirasanBest answer by ikbelkirasan

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

 

View original
Did this topic help you find an answer to your question?
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

steph.n
Forum|alt.badge.img+8
  • Builder
  • 899 replies
  • June 26, 2020

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!


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • June 27, 2020

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


  • Author
  • Beginner
  • 9 replies
  • June 29, 2020

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 :

 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • June 30, 2020

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


  • Author
  • Beginner
  • 9 replies
  • June 30, 2020

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

 

Do you have any pointers?


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • June 30, 2020

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


  • Author
  • Beginner
  • 9 replies
  • July 1, 2020

Hi,

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

 

 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • July 1, 2020

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

  • Author
  • Beginner
  • 9 replies
  • July 1, 2020

@ikbelkirasan 

Thanks for you help!

You mean like this:

 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • Answer
  • July 1, 2020

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

 


  • Author
  • Beginner
  • 9 replies
  • July 1, 2020

@ikbelkirasan 

Thanks! 
It works like a charm now! 

 

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