我想把卷发请求翻译成台风请求。卷曲请求:
@response = %x{curl -i https://track.customer.io/api/v1/customers/#{@client.id} \
-X PUT \
-H "Content-Type: application/json" \
-u #{APP_CONFIG[:customerio][:api_key]}:#{APP_CONFIG[:customerio][:api_key]} \
-d '{
"email":"#{@client.email}",
"name":"#{@client.name}",
"id":"#{@client.id}",
"created_at":"#{@client.created_at.to_time.to_i}"}'}台风请求:
request = Typhoeus::Request.new(
"https://track.customer.io/api/v1/customers/4",
ssl_verifypeer: false,
method: :put,
headers: {
"Content-Type" => "application/json",
"user_agent" => "#{APP_CONFIG[:customerio][:api_key]}:#{APP_CONFIG[:customerio][:api_key]}"},
body: '{
"email":"first@last.com",
"name":"Name is here",
"id":"4",
"created_at":"#{Time.now}"}')当我运行台风请求,我得到一个回应说unauthorized,我相信这表明我的用户信息是不正确的。如何在台风请求中设置等效的-u标志?
发布于 2013-08-09 07:52:57
如何在台风请求中设置等效的-u标志?
在选项哈希中使用userpwd键,例如:
url = "http://httpbin.org/basic-auth/john/pwd1234"
Typhoeus::Request.new(url, userpwd: "john:pwd1234").runhttps://stackoverflow.com/questions/18141452
复制相似问题