Can you make a YouTube analytics API request using Net::HTTP in Ruby? -


assuming access_token , test_channel_id correct, shouldn't request work?

i'm getting 404 error, missing parameter?

uri = uri.parse("https://www.googleapis.com")  http = net::http.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = openssl::ssl::verify_none  request = net::http::post.new("/youtube/analytics/v1/reports") request.body = uri.encode_www_form({"authorization" => "bearer #{access_token}", "ids" => "channel==#{test_channel_id}", "start-date" => "2015-07-01", "end-date" => "2015-07-20", "metrics" => "views"})  response = http.request(request) 

it's worth mentioning obtained access_token refresh_token authorized youtube api scopes

if you're passing access token url parameter, name of parameter should "access_token" , don't need "bearer" part of string; be:

request.body = uri.encode_www_form({"access_token" => "#{access_token}", "ids" => "channel==#{test_channel_id}", "start-date" => "2015-07-01", "end-date" => "2015-07-20", "metrics" => "views"}) 

you use authorization: bearer {whatever}form if you're setting access token in request header.

here's documentation on this.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -