Rails - How to add contacts to SendGrid marketing campaigns via API
I ended up figuring it out. For future reference, here's the code that worked...
require 'rest_client'
api_key = 'YOUR_API_KEY'
headers = {'Authorization' => "Bearer #{api_key}"}
data = {:email => 'email@website.com'}
response = RestClient.post 'https://api.sendgrid.com/v3/contactdb/recipients', [data].to_json, headers
SendGrid add multiple email addresses to Marketing Email API
You could create your :data
param as an array of JSONs, like so:
:data => ['{ "name" : "Foo Bar", "email" : "foo@bar.com" }','{ "name" : "Jon Snow", "email" : "jon@snow.com" }']
Sendgrid (Node JS) add contact to custom Marketing list
So I read the documentation, you can put a list ID within the body of the request,
like this:
"list_ids":["theidofyourlist"], "contacts" ....
Is there a way to build a complete sendgrid subscribtion form using only sendgrid's API?
Twilio SendGrid developer evangelist here.
Yes, you can create your own subscription form. To create a new contact in a list, you can use the create contacts API.
In JavaScript, using the API would look like:
const { Client } = require("@sendgrid/client");
const client = new Client();
client.setApiKey(process.env.SENDGRID_API_KEY);
const request = {
method: "PUT",
url: "/v3/marketing/contacts",
body: {
contacts: [{ email: "test@example.com", first_name: "Test" }],
},
};
client.request(request)
.then(console.log)
.catch(console.error);
Test SendGrid Upsert Cron Job
Twilio SendGrid developer evangelist here.
If you want to make requests to the API as part of your testing (which I normally advise against, as testing 3rd party services should be unnecessary), and you don't want to affect your data, then you don't need a completely new account, but you can use a Subuser account.
SendGrid Marketing Campaigns - Adding Super/Sub script without code
Twilio SendGrid developer evangelist here.
The WYSIWIG section of the template editor for a text block looks like this:
You are not, to my knowledge, missing a superscript option.
When you make a change to the code that is not supported in the WYSIWIG editor, the module must be changed to a code module. As the interface says:
You have made structural HTML changes that this module doesn't support. Typically this happens when you add a tag such as '
<span>
', '<p>
', '<table>
', etc. To keep these changes, convert to a code module.
If you need the superscript, but prefer to use WYSIWIG for most things, you could try to split the text into multiple modules in which the paragraph containing the superscript is a code module, but is surrounded by text modules.
Related Topics
How to Write a Method That Counts the Most Common Substring in a String in Ruby
Rails 3 Translations Within Models in Production
Metasploit Induction of Bundle and Rake
How to Convert Timestamp with Ruby
Calling Protected Class Method from Instance Method in Ruby
Iterate and Set Ruby Object Instance Variables
What Ruby and Rails Developers Ought to Know
Fetch VS. [] When Working with Hashes
When Passing a Ruby Array as an Argument, Why Does '<<' Append While '+=' Does Not
Proc Throws Error When Used with Do End
Is There a Way of Changing Regular Expressions to a Range of Numbers in Ruby on Rails
Rails How to Use Associated Model with the Admin Namespace