HTML to HTTP posting

Hello community!

I have been struggling with posting a HTML through HTTP (see attachment for scenario).

Currently, the output of the last text parser looks like this, with a basic form of

,

and in its content:

    "text": "<p>Wil jullie als vrienden weer eens samen op vakantie, maar weten jullie niet precies waar jullie naartoe moeten? </p><h2>IJsland biedt eindeloos veel avontuur</h2><p>Hou je van een actieve vakantie? Dan hou je van <a href=\\"https://voja.travel/bestemmingen/ijsland/\">IJsland</a>. <h2>Huur een auto en maak een roadtrip door IJsland</h2><p>IJsland is een heel groot land en de beste manier om alle mooie plekken te verkennen, is per auto. Er zijn in het land diverse routes voor je uitgestippeld. De betere reisorganisaties hebben langs deze routes hotels voor je beschikbaar zodat je een complete rondreis kunt boeken. Maak je avontuur compleet door te gaan kajakken op het J&ouml;kuls&aacute;rl&oacute;n gletsjermeer. Je vaart door een magisch winterlandschap waar je spectaculaire foto&rsquo;s kunt schieten. </p><h2>Boek een compleet verzorgde reis voor een perfecte vakantie</h2><p>Waarom zou je het jezelf moeilijk maken en zelf je hele reis uitstippelen? Kijk een keer op <a href=\\"https://voja.travel/\">Voja.Travel</a>&nbsp;om te zien welke compleet verzorgde reizen je hier kunt boeken. Je vindt hier rondreizen langs de mooiste plekken van IJsland waarbij al je overnachtingen inbegrepen zijn. Zij zorgen er graag voor dat jullie reis onvergetelijk wordt. We wensen jullie een heel fijne vakantie.</p>"

However, when posting this in HTTP (see 2nd attachment), it results in an error.

Where is the fault? How come this text doesn’t post properly?

Looking forward to replies!

Kind regards,
Onno

image

image

Escaping strings before mapping into another JSON string

Most of the time, you cannot directly map variables containing text content into another JSON string without escaping them, as the variable might contain characters that have a special meaning in JSON.

Special characters in strings needs to be specified (escaped) as a “literal” character (instead of a special metacharacter), otherwise they make the whole JSON invalid when you map the variable value when creating another JSON string.

You can escape string variables by passing the text into the JSON “Transform to JSON” module —

Transforms any object to JSON.

Then, you can map the output of the “Transform to JSON” module into your JSON string. (Do note that when using the “Transform to JSON” module, the output should already contain the double quotes " " around your text, so when you map this output into your JSON, you should not need to wrap another pair of double quotes around it.)

Alternatively, you can use the built-in function replace to replace those special characters with their escaped versions, as discussed here.

Alternatively, you can build your whole JSON in the “Create JSON” module, and mapping only the output of this module into the “Request Content” field.

For more information on escaping JSON strings, see: Understanding JSON Escape: A Comprehensive Guide

Hope this helps! Let me know if there are any further questions or issues.

@samliew