Search code examples
amazon-web-servicesurlencodeamazon-selling-partner-api

Amazon sp-api incorrect URL encoding / decoding characters while updating quantity


I have an issue when including the special characters such as "#" in Amazon Listing API. For example, the sku, HP-2DP98AA#ABC-200621 will be updating the quantity at 20. However, Amazon API responses InvalidSignature

I did apply the encoding for the SKU before submitting the request to Amazon, but it is failed all the time. Any idea?


Solution

  • the AWS documents selling-partner-api-docs Rest API about how to patch the items URL is PATCH /listings/2020-09-01/items/{sellerId}/{sku}. This means that sku need to add in URL which contains "#" like this.

    /listings/2020-09-01/items/{your sellerId}/HP-2DP98AA#ABC-200621
    

    This request URL would be cause the exception or InvalidSignature from AWS , because "#" in URL need to encode "#" to "%23" such as below:

    /listings/2020-09-01/items/{your sellerId}/HP-2DP98AA%23ABC-200621
    

    Also, need to add sellerId, marketplaceIds, and sku parameters as well.

    Additionally, AWS4 Canonical Request is like below:

    AWS4 Canonical Request: '"PATCH
    /listings/2020-09-01/items/{your sellerId}/HP-2DP98AA%2523ABC-200621
    marketplaceIds={your marketplaceIds}&sellerId={your sellerId}&sku=HP-2DP98AA%23ABC-200621
    content-type:application/json; charset=utf-8
    host:sellingpartnerapi-na.amazon.com
    x-amz-access-token:Atza|...
    x-amz-date:20210831T190152Z
    x-amz-security-token:Fwo...
    
    content-type;host;x-amz-access-token;x-amz-date;x-amz-security-token
    d1809d68......"