0
我想創建一些簡單的Ruby代碼來使用Campaign Monitor API添加電子郵件。以下是我的代碼。無法將電子郵件添加到Campaign Monitor 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
文檔