lineofflight / peddler

Amazon Selling Partner API (SP-API) in Ruby
MIT License
307 stars 130 forks source link

list_matching_products can’t get correct data when queries are multibyte characters #84

Closed magicalmongolpanda closed 7 years ago

magicalmongolpanda commented 7 years ago

Hi, I use the peddler on JP marketplace. I can't get correct data when using list_matching_products by multibyte characters. Does Peddler encode queries in the following way (quoted from http://docs.developer.amazonservices.com/en_US/dev_guide/DG_QueryString.html)?

To create the query string to be signed, do the following:

  1. Sort the UTF-8 query string components by parameter name with natural byte ordering. The parameters can come from the GET URI or from the POST body (when Content-Type is application/x-www-form-urlencoded).
  2. URL encode the parameter name and values according to the following rules:
    • Do not URL encode any of the unreserved characters that RFC 3986 defines. These unreserved characters are A-Z, a-z, 0-9, hyphen ( - ), underscore ( _ ), period ( . ), and tilde ( ~ ).
    • Percent encode all other characters with %XY, where X and Y are hex characters 0-9 and uppercase A-F.
    • Percent encode extended UTF-8 characters in the form %XY%ZA....
    • Percent encode the space character as %20. Do not percent encode the space character as +, as some common encoding schemes do.
  3. Separate the encoded parameter names from their encoded values with the equals sign ( = ) (ASCII character 61), even if the parameter value is empty.
  4. Separate the name-value pairs with an ampersand ( & ) (ASCII code 38).
  5. Create the string to sign according to the following pseudo-grammar (the "\n" represents an ASCII newline).
    StringToSign = HTTPVerb + "\n" +
    ValueOfHostHeaderInLowercase + "\n" +
    HTTPRequestURI + "\n" +
    CanonicalizedQueryString <from the preceding step>

    The HTTPRequestURI component is the HTTP absolute path component of the URI up to, but not including, the query string. If the HTTPRequestURI is empty, use a forward slash ( / ).

hakanensari commented 7 years ago

@magicalmongolpanda, thanks for reporting this. master branch should fix this issue.