Solved

Use Latest Public Comment in Web Request in Workflow Automator

  • 8 October 2022
  • 6 replies
  • 188 views

Userlevel 1
Badge

I am trying to get the latest public comment and pass it to the 3rd application using web request in workflow automator. I am sure there is something in that field. However, I am not able to insert it into my JSON body to to send it the REST call. It throws the invalid JSON format error. I tried to add and remove the quotes around the bird lip brackets, still no luck.

Mine looks something like this:

{
"work_notes": "{{ticket.latest_public_comment}}"
}

Do I have to do anything different with it?

**sorry if this is in the wrong forum. My first post here **

Thanks,

Sam

icon

Best answer by Daniel Söderlund 12 October 2022, 12:10

View original

6 replies

Userlevel 7
Badge +14

Hello @SamAtNAIT lets see if we can get this moved to the correct area so that our freshservice community experts can help you solve your issue.

@rashmi.nag would you mind moving this to the freshservice community threads? Thank you :)

Userlevel 7
Badge +9

Hi @SamAtNAIT. Welcome to the Freshworks Community and I have already moved it to the Freshservice forums and alerted our product experts to take a look at your question :)

Thanks for the heads-up, @zachary.king :)

Userlevel 4
Badge +5

Hello @SamAtNAIT

Hope you are well, 

Could you try using the Test Web Request in the Workflow and adding a dummy value to this placeholder and check the working? We'll be prompted with errors and would be able to check further if we're missing out something.

Thanks! 

Userlevel 4
Badge +5

Hello @SamAtNAIT , 

Greetings to you! 

Would you be able to help us with the endpoint url, Payload and creds at support@freshservice.com? We would be able to test out what's causing the error and can you sort it out. 😉

Userlevel 7
Badge +11

I am trying to get the latest public comment and pass it to the 3rd application using web request in workflow automator. I am sure there is something in that field. However, I am not able to insert it into my JSON body to to send it the REST call. It throws the invalid JSON format error. I tried to add and remove the quotes around the bird lip brackets, still no luck.

Mine looks something like this:

{
"work_notes": "{{ticket.latest_public_comment}}"
}

Do I have to do anything different with it?

**sorry if this is in the wrong forum. My first post here **

Thanks,

Sam

Need to use this 

 

Sanitize HTML content using sanitize_html Liquid Placeholder

 

Use the sanitize_html liquid filter to treat HTML placeholders so that they can be used within the body of an API request without an invalid JSON error being thrown.

 

For example:

 

{{ticket.description}}  returns
 

"<div style='font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;'>\n<div>This is test.</div>\n</div>"

 

{{ticket.description | sanitize_html}}  returns

 

"<div style='font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, \\\"Segoe UI\\\", Roboto, \\\"Helvetica Neue\\\", Arial, sans-serif;'>\\n<div>This is test.</div>\\n</div>"

 

And thus can be used within the body of an API request.

 

Can read about it here Powerful Placeholders with Liquid Filters : Freshservice

And Introduction – Liquid template language (shopify.github.io)

 

Userlevel 1
Badge

Thank you so much @daniel.soderlund ! The liquid placeholder is very handy. I also needed to strip the html so this is what it ended up to be and it worked:

{
"work_notes": "{{ticket.latest_public_comment | sanitize_html | strip_html}}"
}

Thank again!

Sam

Reply