Web Connection
Amazon URL Encoding Schema help
Gravatar is a globally recognized avatar based on your email address. Amazon URL Encoding Schema help
  Gary
  All
  May 12, 2017 @ 02:29pm

I'm trying to URL encode parameters that I'm going to be passing to Amazon's API and the addpostkey() function is encoding things differently than the Amazon encoding specs (see below) is there another function in the West Wind tools that will encode according to this schema?

AMAZON urlendode procedures:

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). 

The starndard addpostkey() urlencoding function is not endocding in this manner.

Any direction is appreciated.

Gary

Gravatar is a globally recognized avatar based on your email address. re: Amazon URL Encoding Schema help
  Rick Strahl
  Gary
  May 12, 2017 @ 11:21pm

Nope.

UrlEncoding is pretty standard and if Amazon expects something different you'll have to manually encode the text.

If I understand this right though this should all be fine with what WWWC does except for the spaces and tildes which you would have to post process.

Pretty lame that they can't handle that because that's pretty common - there's no conclusive rules one way or the other and most parsers can handle characters that are encoded either way.

Another option you can try - call the .NET UrlEncode functions using wwdotnetbridge. But if I remember right they too don't handle this quite the same way and I'm not sure what exactly they do with UTF-8 extended characters. Pretty sure it won't create those double byte encodings either.

+++ Rick ---

© 1996-2024