码迷,mamicode.com
首页 > 其他好文 > 详细

解决方案

时间:2017-12-11 20:36:15      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:api   res   ssi   response   grant   example   com   tom   ret   

https://stackoverflow.com/questions/5957185/rest-client-ruby-gem-headers

 

@result = RestClient.post(
          ‘url‘,
          {:billingSourceCode => "code"},
          {:headers => {‘Content-Type‘ =>‘application/json‘, 
                       "Authorization" => "key",  
                       "Accept" => "application/json"},
                       {:cookies => {:session_id => "1234"}}
          })

The params for the email is not in quotes. {"email": email@example.com, "password": password}. 


hHeader = {"X-AppSecretToken" => ‘tokenID1_sanitized‘, "X-AgreementGrantToken" => ‘tokenID2_sanitized‘, "Content-Type" => ‘application/json‘}

hCustomer = RestClient.get("https://restapi.e-conomic.com/customers/5", hHeader) # => creates a response showing customer 5 (shown for example of GET)
body = {‘address‘ => ‘Example Street‘, ‘name‘ => ‘John Doe‘}.to_json
RestClient.post "https://restapi.e-conomic.com/customers/", body, hHeader)

  

解决方案

标签:api   res   ssi   response   grant   example   com   tom   ret   

原文地址:http://www.cnblogs.com/znsongshu/p/8024843.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!