c# - Posting request to Amazon MWS services -
I was already wasting a few days on this issue ... The main problem is - I do not know how Posting data I would like to start by OrderReferenceDetails (API section: Stop payment to Amazon, Operation: GetOferenceDetails).
As I understand, what I should do is calculate the signature. So using it, and taking values in Scratchpad, I made a string, which I guess was the signature. This string looks like this
posting mws.amazonservices.com/offeramazonpayments_sandbox / 2013-01-01 action = GetOrderReferenceDetails and AmazonOrderReferenceId = [_my order reference ID_] and AWSAccessKeyId = [_My Access key] & Amp; Vendor id = [_ my seller ID_] and signature method = HmacSHA256 and signature version = 2 and timestamp = 2014-11-04 t 12% 3a 15% 3a 38.1988397Z & version = 2013-01-01
So I have taken it hashes and have received the signature, then I should add this query parameter such as and signature = [_ clamped signature] to my line
I use the function to calculate the signature:
Re> Private Static String Sign (String Data, String Secret) {String result = Zero; KeyedHashAlgorithm algorithm = new HMACSHA256 (); Encoding encoding = new UTF 8 encoding; Algorithm.key = encoding Getbytes (secretaries); Result = Convert.Tobase64String (Algorithm.comput hash (encoding .gatebits (DataTookerAmerge))); Return result; }
The problem started here (I think). Scratchpad provides "data" for posting, but I do not understand how to use it (copy paste from Scratchpad):
Post / OffAmazon Payment Spell Checkbox / 2013- 01-01? AWSAccessKeyId = & amp; Action = GetOrderReferenceDetails and SellerId = & amp; SignatureVersion = 2 and Timestamp = 2014-11-04T12% 3A37% 3A58Z and version = 2013-01-01 and signature = RECRKP27PHKLU% 2BAmRLR% 2ByRpUtfhNsVOWuGTQ7s% 2FgkB2w% 3D and signaturemap = HmacSHA256 and AmazonOrderReferenceId = http / 1.1 host: mws .amazonservices.com x-amazon-user-agent: AmazonWascript process pad / 1.0 (language = JavaScript) content-type: text / xml
What's this? I am familiar with the request like this:
HTTP WebBrover Request = WebAuruify HTTP webboot as URL (URL); request. Method = "post"; Request.ContentType = "text / xml"; Request.Host = "Host which I need to use"; Request.ContentLength = encoding.UTF8.GetByteCount (DataAstString); Byte [] Bytere = encoding. UTF8.GetBytes (DataAstString); (Stream datastream = request using gateratequeststream ()) {datastream.Write (bytes, 0, byte length); } Try {HttpWebResponse response = request.GetResponse (); HttpWebResponse; (Stream Streamer = New Stream Reader (Response: GatorponsSstream ()) (String ResponseAstString = Stream Reader. Readout);}} Catch (Web Exception Exception) {HTTP Webpages Extra Response = Exceptions. Http Webbashan's Answer in the form; (Var Streamer = New Stream Reader (Extra Response. Gatorresonsstream ()) (String Response Eststring Question:
The questions are:
Am I calculating the signature correctly?
Edit:
OK, I finally got MWS from Amazon Received a response, this is not an error!
Create the URL where I will post the data with my hands - again, I have to work it out Did:
The creation of the string which will be signed by the hand of the query parameters. The command is important, but different from the string before it. The key in the signed string is sorted based on the wordpress sort byte sequence. should go. Well, I do not know what type of animal is, so I did everything by hand, for example taking a scratchpad.
Comments
Post a Comment