Error 404 with Loops.so when using App text to replace variable

Hello everyone,

I want to send emails with loops.so using App text dynamic data. When I replace variables with App text dynamic data, the json is certainly not clean so I have an 400 error. Without App text, all goes well. How to resolve this issue? I tried :formatted as Json safe but this did not work (on one App text’s value).

Modified: error 400 not 404

@nick.carroll

thanks for you help!

404 is not related to JSON but to incorrect url endpoint.

Sorry I meant 400 not 404!

Can you share your settings in API connector and in action with dynamics data?

Pretty sure your issue is that you are not using json-safe or you don’t use it correctly.

Hi Jici, thank you for looking at it. I can send emails with loop.so with dynamic data such as Input xxx’s value or Current User’s email but as soon as include App text. I have this 400 error… (I didn’t send the API connector because it works when I don’t use App text and I modified it for testing so it won’t match with the wf where I had errors). Can you see the way I use App text is wrong? I just replace var by the dynamic App text…

If you data contain special characters, this could broke your JSON.
The best is to test by sending the request to service like beeceptor and validate the JSON.

From my point of view, each “part” and probably SubjectInvitation should be encoded like:
"Part1":App text (Invitationpart1):formatted as json-safe'
If you look carefully, you can see that I didn’t add double quotes around dynamic data because :formatted as json-safe will do it.

Thank you for following this up. I found why the JSON broke. I had line breaks in my App Text. I replaced them all with < br >
and it now works! :star_struck:

Using json-safe is made for this. This is one of the best thing you can do when using JSON API call instead of using find and replace function.

My guess is the App text value contains characters (line breaks, quotes, or special HTML) that are breaking the JSON structure when it gets sent to Loops.

A few things to try:

  1. Make sure :formatted as JSON safe is applied to each App text field individually, not just one of them.
  2. Check if the App text has any line breaks — those need to be stripped or the JSON will break. Try adding :converted to text and then :find and replace to remove any \n characters.
  3. Can you share a screenshot of the workflow action where you’re passing the variables to Loops? That’ll let me see exactly how the body is structured and where the issue likely is.