Best answer

New lines in Webhook field causing JSON payload error

  • 21 July 2021
  • 8 replies
  • 33 views

I have a Zap that pulls information from a Task in Freshsales, then appends a URL to the end of the description field.  It works fine MOST of the time, however it fails whenever the description has new lines in it.  It reads the description just fine in the initial step, but when it PUTs the data back I get the error “The app returned "There was a problem in the JSON payload".”

I assume there’s some way to translate those new lines into something Freshsales recognizes, but I have no clue how to do that, and it is strange that it outputs it in that format but won’t accept it as an input.

Thanks in advance!

icon

Best answer by SGS 28 July 2021, 22:37

Resolved the issue.  This is an undocumented part of Freshsales API that new lines need to be encoded as \n

I will do a formatter step to replace them.  Is there any out of the box formatter settings to replace everything that needs to be encoded as a slash command?

View original

8 replies

Userlevel 7
Badge +10

Hi @SGS 

Try using the Formatter as a Zap step: https://zapier.com/help/doc/how-use-formatter-functions

I looked at that formatter help file and it looks like there are a lot of different formatter functions (and even more in the app than are in the help file).  Which one should I use?

Userlevel 7
Badge +10

@SGS 

Try this Formatter > Text > Convert HTML to Markdown

TIP: When in doubt, test it out!

Tried both that and markdown to HTML, no improvement.

Userlevel 7
Badge +10

@SGS 

You may have to try using a custom Code step to clean up the data: https://zapier.com/apps/code/help

Resolved the issue.  This is an undocumented part of Freshsales API that new lines need to be encoded as \n

I will do a formatter step to replace them.  Is there any out of the box formatter settings to replace everything that needs to be encoded as a slash command?

Userlevel 7
Badge +10

@SGS 

Try using Formatter > Text > Replace

https://zapier.com/help/create/format/modify-text-formats-in-zaps#find-replace-or-split-special-characters

Yeah, that’s what I’m doing, just wondering if, just like HTML<->Markdown there was any other mass formatter for catching characters like that (whatever thy are called).  Thanks for your help.

Reply