【问题标题】:Pass parameters in AccessToken post request for gem Oauth rails在 Gem Oauth rails 的 AccessToken 发布请求中传递参数
【发布时间】:2017-02-08 06:43:24
【问题描述】:

我正在尝试对 gem Oauth 的 AccessToken 类进行 POST API 调用。但是我收到了奇怪的回复,所以任何人都可以让我知道拨打电话的确切方法是什么。

实施-1:

access_token.post('/organizations/223031/files', { 'name' => '10.3.199_export.zip' }.to_json(),
{ 'Accept'=>'application/vnd.deere.axiom.v3+json', 'Content-Type' => 'application/vnd.deere.axiom.v3+json' })

我得到了正确的回应。

实施 2:

access_token.post('/organizations/223031/files',
:body => {:name => 'xyz.zip'}.to_json,
:headers => { 'Content-Type' => 'application/vnd.deere.axiom.v3+json', 'Accept'=>'application/vnd.deere.axiom.v3+json'})

对于这个电话,我提到了这个link,但得到了 404 错误。

所以我有以下疑惑:

  • 根据我的理解,implementation-1 是正确的(如果我错了,请纠正我)至于获得正确响应,而对于 implementation-2 获得 404错误。那么它们之间的实际区别是什么。
  • 最好的方法是什么。

【问题讨论】:

    标签: ruby-on-rails ruby oauth


    【解决方案1】:

    你必须对:body:headers 使用字符串哈希火箭,不过我更喜欢Implementation-1

    access_token.post('/organizations/223031/files',
      "body" => {"name" => 'xyz.zip'},
      "headers" => { 'Content-Type' => 'application/vnd.deere.axiom.v3+json', 
        'Accept'=>'application/vnd.deere.axiom.v3+json'})
    

    【讨论】:

      猜你喜欢
      • 2013-12-22
      • 1970-01-01
      • 1970-01-01
      • 2019-07-19
      • 1970-01-01
      • 2020-06-07
      • 2021-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多