[英]Can't add facebook promoted_object field to campaign during graph api call for posting ads on facebook
[英]Can't add email to Campaign Monitor API?
我正在嘗試創建一些簡單的Ruby代碼,以使用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' => 'mike@hotmail.com',
'Name' => 'Test',
'Resubscribe' => true,
'RestartSubscriptionBasedAutoresponders' => true
})
puts response
puts response.code
end
request
我可以連接API。 但是,當我嘗試添加電子郵件時,收到以下響應。
{“代碼” => 400,“消息” =>“未能反序列化您的請求。
請檢查文檔,然后重試。
錯誤字段:訂戶“}
400
當我更改get
而不是put
請求時,我的答復是:
{“代碼” => 1,“消息” =>“無效的電子郵件地址”}
我遵循了Campaign Monitor API上的文檔,因此我無法理解自己在做什么錯
看起來您已正確設置了所有內容,只需要將帖子的正文轉換為json字符串。
response = HTTParty.post(url,
:basic_auth => auth, :body => {
'EmailAddress' => 'mike@hotmail.com',
'Name' => 'Test',
'Resubscribe' => true,
'RestartSubscriptionBasedAutoresponders' => true
}.to_json)
我想指出的是,還存在Campaign Monitor API gem,它將為您完成所有這些工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.