代码之家  ›  专栏  ›  技术社区  ›  user3576036

NoMethodError:使用httparty时哈希的未定义方法“strip”

  •  0
  • user3576036  · 技术社区  · 7 年前

    我正试图通过使用api post请求创建内容,我正在使用httparty gem。

      def initialize(token)
        @token = "Bearer kdkdkfvl"
      end
    
      def auth
        { AUTHORIZATION: @token }
      end
    
    response = HTTParty.post("url", :headers => { "Authorization" => auth}, :body => article)
    

    NoMethodError: undefined method 剥去# ` 我被困在这里了。需要帮助

    1 回复  |  直到 7 年前
        1
  •  2
  •   elliotcm    7 年前

    你在传递一个散列值,它需要一个字符串。

    def auth
      @token
    end
    
    推荐文章