Rails - How to add contacts to SendGrid marketing campaigns via API

前端 未结 2 1879
野性不改
野性不改 2021-01-24 06:01

I need to make HTTP get and post requests with SendGrid to add contacts to our account, however there doesn\'t seem to be a gem for their email marketing functionality.

2条回答
  •  北海茫月
    2021-01-24 06:18

    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
    

提交回复
热议问题