Ruby equivalent of curl with -H (header) switch -


i want curl request does, in ruby:

curl https://api.wheniwork.com/2/shifts/?location_id=1&start=2014-03-05 \ -h "w-token: ilovemyboss" 

the part struggling is: how can add w-token @ end of regular https request?

here's example how can accomplished standard library net/http:

  require 'net/http' url = '...' uri = uri(url) http = net::http.new(uri.host) request = net::http::get.new(uri.path) request['authorization'] = %{token token="#{password}", userid="#{user_id}"} res = http.request(request)  

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -