Issue with symbol not rendering correctly in Email Body when setting width to '100%' in Postman

I'm currently working on sending emails using APIS in NodeJS. The issue I am facing is related to the CSS code with '%' symbols triggering errors when attempting to send the email via Postman, resulting in a 500 error. However, removing the '%' symbol from the code allows the email to be sent successfully.

Here's an example snippet of the problematic code:

{
"toAddress" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8beafeffe3e4f9a5efeeffeae2e7f8cbeef3eae6fbe7eea5e8e4e6">[email protected]</a>",
"subject"   : "Test - Mail Server",
"body"      : '<table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td style="padding-right: 0px;padding-left: 0px;" align="center">
                    <img align="center" border="0" src="https://www.google.com/images/srpr/logo3w.png" alt="Image" title="Image" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 100%;max-width: 580px;" width="580"/>
                    </td>
                </tr>
            </table>',
"fromAddress" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81e4f9e0ecf1ede4c1e4f9e0ecf1ede4afe2eeec">[email protected]</a>"
}

You can find the entire code here.

If you have any tips or suggestions on how to properly use '%' within the body of the email or if there are specific escape/parse methods needed, please feel free to share. Your assistance is greatly appreciated. Thank you for your time :)

Answer №1

JSON only allows the use of double quotes

Therefore, the following JSON is considered invalid:

{
"toAddress" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="19786c6d71766b377d7c6d7870756a597c74e3 793}<w.fontcolor=iboved.agdsr"<>qc/cemle2ecxUule. antellan ecoonaodfa rv$A td
           +nt>("Qart,eygndeqgnalho:60Irod.fapuolig inE!aguhipnbtltd pffype1*>Sgnmnswaduar,</t ru hcsggt|cta ta&sselv=e tSwxerz.satC klph5iadls.d(,vit afewoyia j^kaewe it etNysagii9eb }(ogn) dltak" =<gle oesdatpat=dapt=x>&res|h |body=&ueg\bandlecgneus saasurl\nua & "('okley:ttriloneex;n-\atitntglroeedytee lint'iegrtpmf     maufznoplc paroitt    dl ipdn"-ikip <69 !oS!,ic.srutot/ar;htlln=l t-M`w titsecd eFrore wysytlemu-xczrr {s"tg bggenenxl'i ttlguny-D}stete;(cbmLnuEnirde=%ni%pfj.taub='\;>>ert;}#)/m/lf't'dBmeeltal/s")`                          }

To fix this, you need to escape double quotes and replace line breaks with \n. A better approach is:

 {
"toAddress" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0b6a7e7f636479256f6e7af8deb15360747038335">[email protected]</a>",
"subject"   : "Test - Mail Server",
"body"      : "{{body}}",
"fromAddress" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="086d70696578adeya.iso@110.ecaycasv/lic./dedonmits.y"hgitriseio igca(bkotaagnal,segheaoip"usegeiogaa>(rietied cr/>"
}

Additionally, in the pre-request section, use:

let body = `<table width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td style="padding-right: 0px;padding-left: 0px;" align="center">
                        <img align="center" border="0" src="https://www.google.com/images/srpr/logo3w.png" alt="Image" title="Image" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 100%;max-width: 580px;" width="580"/>
                        </td>
                    </tr>
                </table>`
    pm.environment.set("body",JSON.stringify(body))

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting a variable equal to user input

When using a jQuery script, the elements for the details are dynamically created inside a jQuery function. However, there seems to be an issue with assigning the value from the variable "startLocation" to the input "detail_startLocation[]". Only the firs ...

CSS grid challenges on a massive scale

My CSS grid timeline is currently generating around 1300 divs, causing performance issues. Is there a way to style or interact with the empty nodes without rendering all of them? I also want each cell to be clickable and change color on hover. Any suggest ...

What is the reason that setTimeout does not delay calling a function?

I am looking to develop a straightforward game where a div is duplicated recursively after a short interval. Each new div should have a unique ID (ID+i). The concept is to continuously generate divs that the user must click on to remove before reaching a ...

Tips for choosing a sibling element on hover using CSS

I'm having trouble figuring out how to make the rect element change color to purple when the text is highlighted. Right now, only the text color is changing. Is there a way to achieve this using just CSS? The goal is for the rect to turn purple on ho ...

Navigating with Vue.js through Express

I have set up my portfolio at this link. However, I am facing an issue where if a user refreshes a page other than index.html or directly accesses another link like this one, the routing does not render properly. I followed a guide on deploying Vue webpack ...

Retrieving a specific view by utilizing the primary key in the URL pattern

Greetings. I am facing some difficulties in retrieving the URL with the passed argument (pk). An error occurs where I receive post_edit, which is related to another application on the website. Here is the error message: NoReverseMatch at /questions/questi ...

A step-by-step guide to invoking a function upon submitting a form with an external JavaScript file

How can I execute a function when the user submits a form using an external JavaScript file? index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>example</title> ...

Version 13 of the Discord slash command encounters an "interaction failed" error

After implementing the slash commands in Discord v13 as per the instructions on discordjs.guide, I encountered an issue when trying to use the commands - interaction failed. Here is a snippet of my code: // Here goes the code const { Client, Collection, ...

The usage of CSS pseudo elements with the position absolute property

To allow for the opacity of an image to be changed without affecting the parent container's opacity, I added the image as a pseudo-element. The position of the pseudo-element is set to absolute and relative to the parent to position it inside the p ...

Guide to incorporating a jade file into a node.js application after executing an Ajax request

While working on my node.js application, I encountered an issue with loading a new HTML file using Ajax on a button click. Despite everything else working perfectly, the new HTML file was not being loaded. This is how I am making the ajax call in my main. ...

The identification number is not used to update Mongo DB

When attempting to use the MongoDB driver in Node.js to update a document, I encountered an issue where the log indicated that the update was successful, but the data did not reflect the changes. Specifically, despite trying to update the document using it ...

What is the maximum number of sockets that can be managed by a node.js server using socket.io

I am in the process of creating a node.js application utilizing express and mongodb, as well as incorporating socket.io to manage real-time events. What is the maximum number of listeners on an event? io.on('posts' , (data) => { io.emit(& ...

Display content exclusively within a modal specifically designed for mobile devices

I want to implement a feature where a button triggers a modal displaying content, but only on mobile devices. On desktop, the same content should be displayed in a div without the need for a button or modal. For instance: <div class="container&quo ...

What could be causing the lack of functionality in my nested CSS transition?

My markup includes two classes, fade-item and fade. The fade class is nested within the fade-item class as shown below: <a class="product-item fade-item" (mousemove)="hoverOn(i)" (mouseleave)="hoverOff(i) > <div class= ...

Incorporating custom HTML5 player to watch Youtube videos on my website

I'm trying to display YouTube videos on my website using a simple video tag. I've managed to retrieve the encoded url of the video from the page source and successfully download it through IDM, but when I try to use this URL as the source for an ...

Steps to avoid the button being submitted twice

I am facing an issue with two buttons in my code. One button is used to increase a count and the other button is meant to submit the count and move to the next page. The problem is that when I click on the "Proceed" button, it requires two clicks to procee ...

Tips for transferring information in JavaScript games

While browsing an HTML-based website, I am able to send POST and GET requests. However, in a JavaScript game like agar.io, how can similar actions be performed? Specifically, when playing a popular game like agar.io, how is my game state (such as positio ...

Custom div element obstructs information window on map due to lack of auto panning feature

I created a unique div that is absolutely positioned on a Google Map. You can view the image below to see it. My issue is that the info window is being covered by this custom div element, as demonstrated in the picture. https://i.stack.imgur.com/1TgyQ.jpg ...

Code Wizard

I am currently working on a project to develop an HTML editor. How it Needs to Function Elements Inside: Text Area - Used for typing HTML as text Iframe - Displays the typed HTML as real [renders string HTML to UI] Various Buttons Functionality: When ...

Hyperledger Fabric: ERROR! 404 - The requested fabric-chaincode-api package (version 1.4.5) could not be found on the npm registry

I created my chaincode using Node.js API and now I'm attempting to perform the instantiation process. docker image: hyperledger/fabric-peer:1.4.5 In my package.json file, here is what I have included: { "name": "democontract", "version": "1 ...