hakanensari / jeff

Minimum-viable Amazon Web Services client
MIT License
24 stars 12 forks source link

400 Bad Request #6

Closed bernstein7 closed 9 years ago

bernstein7 commented 9 years ago

Hello, Hakan

I need to use ItemLookup query. Simply find by ItemId. So I'm building simple request like

2.1.2 :044 > req
 => #<Vacuum::Request:0x000000029d96b0 @aws_endpoint="http://webservices.amazon.com/onca/xml", @aws_access_key_id="MYAWESOMEKEYID", @aws_secret_access_key="andmyawesomesecretkey", @connection=#<Excon::Connection:29c0570 @data={:chunk_size=>1048576, :ciphers=>"HIGH:!SSLv2:!aNULL:!eNULL:!3DES", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"Jeff/1.3.0 (Language=Ruby; X55VD)"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>true, :persistent=>false, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.45.3 (x86_64-linux) ruby/2.1.2", :write_timeout=>60, :host=>"webservices.amazon.com", :hostname=>"webservices.amazon.com", :path=>"/onca/xml", :port=>80, :query=>nil, :scheme=>"http", :expects=>200} @socket_key="http://webservices.amazon.com">>

And send

response = req.item_lookup(query: { 'ItemId' => '9785845917461' })

And got

Excon::Errors::BadRequest: Expected(200) <=> Actual(400 Bad Request)

It seems credentials are valid, otherwise Response code would be 403

I also tried different params and another queries, but got the same response.

So I hope you can help me with that. Thank you.

hakanensari commented 9 years ago

You can rescue the error and introspect the response to see what Amazon specifically complains about.

Here it's probably a missing IdType parameter.

bernstein7 commented 9 years ago

I'm going to dig deeper to see what Amazon specifically complains about, but it seems IdType param missing isn't the reason.

ItemSearch request hasn't IdType param

2.1.2 :006 > response = request.item_search(
2.1.2 :007 >       query: {
2.1.2 :008 >           'Keywords' => 'Architecture',
2.1.2 :009 >           'SearchIndex' => 'Books'
2.1.2 :010?>       }
2.1.2 :011?>   )
Excon::Errors::BadRequest: Expected(200) <=> Actual(400 Bad Request)