How to send data with html tag in Postman body request?

Viewed 4065

I need to save data with html tag in Postman body request (raw/JSON) format via HTTP post method. When I tried it throws error as like the following image. How can I send data with html tag (What I see is what you get - WYSIWYG) in postman body?

enter image description here

3 Answers

There is no single quotes in JSON and there shouldn't be an ending comma ,

Enclose the value of content with double double quotes instead of single quotes and remove the comma after content value

The JSON seems to be not formatted correctly. Did you try to replace unexpected sequences like the \r before you POST the JSON again?

You could encode the html into a base64 string and pass the string in postman.This can later be decoded to the original html once the request body is received in the codebase.

For the encoding and decoding you can use btoa and atob.A reference on this can be found in this link

An example of encoding the html string would look like this:

let htmlstring =`<html>
                <body>
                <p>This is test html</p>
                </body>
                </html>`
let htmlencodedString = btoa(htmlstring); // pass this htmlencodedString in the postman body

An example of decoding this would look like this:

let decodedString = atob(htmlencodedString); // this will give back the original html
Related