Setting Request Headers in Ruby

后端 未结 4 1898
忘掉有多难
忘掉有多难 2021-01-31 16:32

I have the rest client gem and I am defining a request like this:

url = \'http://someurl\'
request =  {\"data\" => data}.to_json
response = RestClient.post(ur         


        
4条回答
  •  广开言路
    2021-01-31 16:37

    The third parameter is the headers hash.

    You can do what you want by:

    response = RestClient.post( 
      url, 
      request,
      :content_type => :json, :accept => :json, :'x-auth-key' => "mykey")
    

提交回复
热议问题