bent0b0x / amazon-mws

MIT License
14 stars 8 forks source link

7 - use mws-compatible uri encoding #10

Closed bent0b0x closed 5 years ago

bent0b0x commented 5 years ago

Issue

7

Context The uri encoding being performed by this library is not entirely compatible with the MWS back-end. Specifically, characters like "!" and "'" are not encoded by encodeURIComponent, but MWS requires them to be.

Work Done Encode all characters required by MWS back-end when constructing request url.

Notes This encoding should be fully compatible now. I copied the algorithm from amazon's own MWS scratchpad: https://mws.amazonservices.com/scratchpad/index.html

cc @trss

bent0b0x commented 5 years ago

@trss to be upfront, I have not been able to fully test this code 😓. I no longer have an amazon seller account, so I do not have a way to end-to-end test w/ the MWS BE. However, I'm going to merge this and then ship a beta npm package release that you can install and test locally 🙏

trss commented 5 years ago

I copied the algorithm from amazon's own MWS scratchpad: https://mws.amazonservices.com/scratchpad/index.html

Very neat! I was able to find it too commented as: Performs URL encoding compatible with MWS http requests

Nevertheless, sharing a few SO Q&A I found useful in the context of this fix: