[Need Help] Sending Emails with Large HTML

Hey, guys I am building a tool for sending Newsletter with HTML emails, I am using the SendGrid API, however, the HTML I scrape comes like this (link below):

https://justpaste.it/dgben

I want to create a new version of a template:

POST https://api.sendgrid.com/v3/templates/[template id]/versions
{
  "active": 1,
  "name": "<Your Version Name>",
  "html_content": "<Your HTML Content>",
  "plain_content": "<Your Plain Text Content>",
  "subject": "<Your Email Subject>",
  "editor": "code"
}

When I send it via API I get:

There was an issue setting up your call.

Raw response for the API 
Status code 400
{"error":"The request could not be completed due to malformed JSON."}

When I paste it manually in SendGrid as a template version it works perfectly.

Any ideas?

Thanks

Your HTML isn’t formatted correctly and is breaking the JSON.

If you need an HTML builder or email sender feel free to checkout :

How did you structure the parameters?

“” will break when JSON incompatible characters are used in the parameter. Almost all the time, inputs in API calls should be surrounded by no quotation marks, and should be :formatted as JSON safe in the API call action in the workflow (which guarantees your JSON is always valid)

This topic was automatically closed after 70 days. New replies are no longer allowed.