Я пытаюсь создать простой Ruby-код для добавления писем с помощью API мониторинга кампании. Ниже мой код.Не удается добавить письмо в API мониторинга кампании?
require 'httparty'
require 'json'
def request
url = 'https://api.createsend.com/api/v3.1/subscribers/MYLISTID.json'
auth = {:username => 'MYAPIKEY', :password => 'x'}
response = HTTParty.post(url,
:basic_auth => auth, :body => {
'EmailAddress' => '[email protected]',
'Name' => 'Test',
'Resubscribe' => true,
'RestartSubscriptionBasedAutoresponders' => true
})
puts response
puts response.code
end
request
Я могу соединиться с API. Однако, когда я пытаюсь добавить письмо, я получаю следующий ответ.
{"Code"=>400, "Message"=>"Failed to deserialize your request.
Please check the documentation and try again.
Fields in error: subscriber"}
400
Когда я изменить запрос get
вместо put
мой ответ:
{"Code"=>1, "Message"=>"Invalid Email Address"}
Я не могу понять, что я делаю неправильно, как я следовал документации по Campaign Monitor API