0
我試圖弄清楚如何將數據添加到使用Ruby淨使用post_form時頭:: HTTP的Ruby的Net :: HTTP.post_form數據添加到頁眉
我看到幾個帖子在計算器Add headers to a request in rails 和我看穿https://github.com/augustl/net-http-cheat-sheet/blob/master/headers.rb
但是,我看不出如何做到這一點。這裏是我的代碼
headers = {
'ApiKey' => org_user.api_key,
'Authorization' => "Bearer #{x['access_token']}",
'Content-Type' => 'application/x-www-form-urlencoded'
}
# Send data
params = {"ContactName": org_user.first_name,
"MiddleName": nil,
"LastName": org_user.last_name,
"PrefixId": nil,
"SuffixId": nil,
"ContactUniqueId": nil,
"ContactSourceId": nil,
"Email": org_user.email,
"Fax": nil,
"Phone": nil,
"AddressLine1": nil,
"AddressLine2": nil,
"AddressLine3": nil,
"AddressLine4": nil,
"City": nil,
"State": nil,
"Zip": nil,
"County": nil,
"Country": nil,
"Id": nil
}
x = Net::HTTP.post_form(URI.parse('http://www.cloudapp.net/admin/contact/create/quick/individual'), params)