iamfmjk / etsy

A friendly Ruby interface to the Etsy API
https://github.com/kytrinyx/etsy
MIT License
170 stars 113 forks source link

All Requests = '400 Bad Request' (or so it seems) #74

Closed jmesserer closed 10 years ago

jmesserer commented 10 years ago

It seems that I get a '400 Bad Request' result for any request I try to make. Is something broken or am I missing something?

jeremiahs-mbp:jds jdm$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]

jeremiahs-mbp:jds jdm$ bundle show etsy
/Users/jdm/.rvm/gems/ruby-2.0.0-p353@e/gems/etsy-0.2.5

jeremiahs-mbp:jds jdm$ irb
2.0.0p353 :001 > require 'rubygems'
2.0.0p353 :002 > require 'etsy'
2.0.0p353 :003 > Etsy.api_key = '***********'
2.0.0p353 :004 > Etsy.api_secret = '************'
2.0.0p353 :011 > Etsy.environment = :production
2.0.0p353 :014 > request = Etsy.request_token
 => #<OAuth::RequestToken ... >

2.0.0p353 :015 > Etsy.verification_url
 => "https://www.etsy.com/oauth/ ... > 

2.0.0p353 :016 > access = Etsy.access_token request.token, request.secret, '5fc35f7b'
 => #<OAuth::AccessToken ... >

2.0.0p353 :018 > access = {access_token: access.token, access_secret: access.secret}

2.0.0p353 :027 > Etsy::Request.get('/shops/9RCSC', access)
 => #<Etsy::Response:0x007f9fa40bc160 @raw_response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>>

2.0.0p353 :028 > Etsy::Request.get('/users/__SELF__', access)
 => #<Etsy::Response:0x007f9fa405fd70 @raw_response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>>

Thanks, Jeremiah
kytrinyx commented 10 years ago

Odd! I'm using the exact same sequence of commands as you are, and I'm getting a 200 OK.

What does Etsy::Request.get('/users/__SELF__', access).body tell you?

jmesserer commented 10 years ago
2.0.0p353 :027 > Etsy::Request.get('/users/__SELF__', access_hash).body
 => "API requests must be made over HTTPS"
kytrinyx commented 10 years ago

Try setting

Etsy.protocol = 'https'
jmesserer commented 10 years ago

That did it! Thanks for the help (and being so responsive).

kytrinyx commented 10 years ago

Glad it worked out! There's an open ticket to improve the README -- this is a friendly reminder to myself that I need to get on it :)