Skip to main content
Question

JSON Error When Sending API Request – Issue with Specific Field

  • March 15, 2025
  • 6 replies
  • 105 views

Hi Guys,

I'm encountering an issue when sending an API request from ManyChat. My JSON structure is as follows:

{  "email": "{{email}}",  "lead_name": "{{cuf_12637843}}",  "book_title": "{{cuf_12637849}}",  "book_price": "{{cuf_12637847}}",  "book_notes": "{{cuf_12637844}}",  "items_rlated": "{{cuf_12637845}}"}

 

 

if i am removing the last line   "items_rlated": "{{cuf_12637845}}" it’s working great! but i dont know what is the issue in cuf_12637845 that i can’t save this json

if i am replcing “cuf_12637845” with “testing” its working, so i guess it’s something related to the field (its a custom text field)

 

 

ERROR I GOT:

Invalid payload json
 

Invalid JSON

Bad control character in string literal in JSON at position 185 (line 7 column 38)

 

 

6 replies

rogerioaraujo
Forum|alt.badge.img+2
  • Flow Scholar
  • March 16, 2025

Click on this custom field that has an error and enable the "Encode to JSON" option. This may solve your problem.


  • Author
  • Up-and-Comer
  • March 16, 2025

STILL THE SAME ISSUE

I Have tried to maek this as “Encode to json” but still the same issue

 


rogerioaraujo
Forum|alt.badge.img+2
  • Flow Scholar
  • March 17, 2025

Your structure is correct. You need to analyze the type of content in this custom field. Generally, when it is of type text or number and you enable the 'JSON encode' option, it works fine. Therefore, there may be some special character in your text that is causing this issue.


Raquel C
Manychat Team Member
Forum|alt.badge.img+3
  • Manychat Community Manager
  • April 1, 2025

hi ​@AmitShemla did you manage to fix the issue?


  • Author
  • Up-and-Comer
  • April 2, 2025

@Raquel C hi

no...


Gustavo Boregio
Forum|alt.badge.img+6
  • Manychat Community Moderator
  • April 2, 2025

Hey ​@AmitShemla did you try the "Encode to JSON" option that ​@rogerioaraujo suggested?

For this to work, you need to check "Encode to JSON" and remove the " " from the JSON code.

If looks like this if you do all text:

{
   "test": {{cuf_11290063|to_json:true}}
}

 

In your case, it'll look like this:

{  "email": "{{email}}",  "lead_name": "{{cuf_12637843}}",  "book_title": "{{cuf_12637849}}",  "book_price": "{{cuf_12637847}}",  "book_notes": "{{cuf_12637844}}",  "items_rlated": {{cuf_12637845|to_json:true}} }

 

The reason for this is that the content of your custom field likely has some characters that need to be escaped to work on the JSON body (characters like /, ", and such). When you remove the " " and do the encode to JSON, Manychat will automatically escape the characters, and it should work.