我想将 curl 请求转换为 Typhoeus 请求。卷曲请求:
@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}"}')
当我运行 Typhoeus 请求时,我收到一条响应,说unauthorized
我相信这表明我的用户信息不正确。如何在 Typhoeus 请求中设置等效的 -u 标志?