HTTP Error 400: GET may not contain a request body
Opened this issue · 1 comments
Deleted user commented
So today my scripts started returning this when I try to auth myself:
[...]/2.1.1/lib/ruby/gems/2.1.0/gems/beeminder-0.2.8/lib/beeminder/user.rb:181:in `block in _connection': request failed: 400 / Bad request (GET and HEAD requests may not contain a request body) (RuntimeError)
from [...]/2.1.1/lib/ruby/2.1.0/net/http.rb:853:in `start'
from [...]/2.1.1/lib/ruby/gems/2.1.0/gems/beeminder-0.2.8/lib/beeminder/user.rb:164:in `_connection'
from [...]/2.1.1/lib/ruby/gems/2.1.0/gems/beeminder-0.2.8/lib/beeminder/user.rb:103:in `get'
from [...]/2.1.1/lib/ruby/gems/2.1.0/gems/beeminder-0.2.8/lib/beeminder/user.rb:43:in `initialize'
[...]
So apparently Beeminder's API no longer accepts GET requests with a body. The gem sets the auth_token like this, in user.rb / _connection():
api = "https://www.beeminder.com/api/v1/#{cmd}"
data = {@token_type => @token}.merge(data)
[...]
http.start do |http|
req = case type
when :post
Net::HTTP::Post.new(url.path)
when :get
Net::HTTP::Get.new(url.path)
when :delete
Net::HTTP::Delete.new(url.path)
when :put
Net::HTTP::Put.new(url.path)
else
raise "invalid connection type"
end
req.set_form_data(data)
res = http.request(req)
I don't know how else to set up GET requests or how else I'm supposed to sanely use Ruby's httplib. Would be cool if someone who understands this could fix it / point me to how to do GET requests properly.
Deleted user commented
(fixed in 0.2.9)