amzon SP-API ,The request signature we calculated does not match the signature you provided

Viewed 870

Errors appear when I encrypt and upload the feed data

the document link :https://github.com/amzn/selling-partner-api-docs/blob/main/guides/use-case-guides/feeds-api-use-case-guide-2020-09-04.md#step-2-encrypt-and-upload-the-feed-data

I develop in php,and the composer is composer require double-break/spapi-php

$feeder = new Feeder();
$feeder->uploadFeedDocument($docPayload, 'text/plain; charset=utf-8',
        //ROOT_PATH.'uploads/amz/'.$feedFileName
        'https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_4_1/OrderAcknowledgement.xsd'
    );

Errors appear when I encrypt and upload the feed data:

enter image description here

2 Answers

Make sure content type you pass to createFeedDocument matches exactly the content type you pass to Feeder::uploadFeedDocument. In my case I was passing text/tab-separated-values to the former but text/tab-separated-values; charset=UTF-8 to the latter (with charset appended) and was getting the error you're describing. I fixed it by passing text/tab-separated-values; charset=UTF-8 in both instances.

I agree with this comment https://stackoverflow.com/a/67474344/12360781

But a more elaborative answer would be that we should pass these headers to the PUT request and of course the content-type should be the same as we passed to CreateFeedDocument operation.

{"Content-Type": "text/tab-separated-values; charset=UTF-8"}

This piece of code worked for me in Ruby:

faraday_connection = Faraday::Connection.new(@url)

@response = faraday_connection.send(:put, nil, @data.to_json, { "Content-Type": "text/tab-separated-values; charset=UTF-8" })

Related