All requests get "Missing service parameter" error
cambridgemike opened this issue · 8 comments
Every request I make ends up with the error:
Your request is missing the Service parameter. Please add the Service parameter to your request and retry
For example
>> req.search("books", :power => "foucault", :response_group => "medium")
=> #<Vacuum::Response::ProductAdvertising:0x1021e30b8 @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?><Errors><Error><Code>AWS.MissingServiceParameter</Code><Message>Your request is missing the Service parameter. Please add the Service parameter to your request and retry.</Message></Error></Errors>", @code=200>
Very odd. It must be something in how you set up the request.
This is how I normally do it:
req = Vacuum.new(:product_advertising) do |config|
config.key = KEY
config.secret = SECRET
config.tag = TAG
end
No dice, could something be up with my credentials?
>> req = Vacuum.new(:product_advertising) do |config|
?> config.key = KEY
>> config.secret = SECRET
>> config.tag = TAG
>> end
=> #<Vacuum::Request::ProductAdvertising:0x101f13db0 @endpoint=#<Vacuum::Endpoint::ProductAdvertising:0x101f12c58 @tag="....", @secret="....", @key="....">, @parameters={}>
>> req.search("books", :power => "foucault", :response_group => "medium")
=> #<Vacuum::Response::ProductAdvertising:0x101dcac88 @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?><Errors><Error><Code>AWS.MissingServiceParameter</Code><Message>Your request is missing the Service parameter. Please add the Service parameter to your request and retry.</Message></Error></Errors>", @code=200>
Using gem version vacuum (0.2.2)
After you get the error, check what req.parameters
contains. That should give a hint.
Strange, it has a service parameter "Service"=>"AWSECommerceService"
I dug into it a little bit, it looks like Addressable::URI doesn't respect passing :query_values in as a param to the initializer. See example...
>> uri = Addressable::URI.new :query_values => {'Action' => 'GetCompetitivePricingForASIN', 'ASINList.ASIN.1' => '....', 'MarketplaceId' => 'ATVPDKIKX0DER'}, :host => "amazon.com"
=> #<Addressable::URI:0x87ad3d4c URI://amazon.com>
>> uri.query
=> nil
>> uri.query_values = {'Action' => 'GetCompetitivePricingForASIN', 'ASINList.ASIN.1' => 'B00655AUPY', 'MarketplaceId' => 'ATVPDKIKX0DER'}
=> {"Action"=>"GetCompetitivePricingForASIN", "MarketplaceId"=>"ATVPDKIKX0DER", "ASINList.ASIN.1"=>"...."}
=> #<Addressable::URI:0x87ad3d4c URI://amazon.com?ASINList.ASIN.1=....&Action=GetCompetitivePricingForASIN&MarketplaceId=ATVPDKIKX0DER>
Thanks for getting to the bottom of this
(Addressable needs to be version 2.2.7 or higher)
Adding this comment so people in the future find it here instead of finding it by going to his fork, looking at each of his commits and implementing them to a fork of the current version from here. :)
Maybe it'd help if you added that requirement to the vacuum gemfile?