Upload PDF invoice to Amazon using SP-API in Postman [UPLOAD_VAT_INVOICE]

How do I upload a PDF invoice to Amazon using SP-API in Postman?
(In MWS the feed was known as UPLOAD_VAT_INVOICE)

I found the following document for the topic at hand:

Unfortunately the most important step, the upload itself, is just listed as:
“2. Upload your feed document contents to the URL from the previous step.”

I got the “feedDocumentId” and the “url” from the first step, but I have no idea how to actually upload the PDF invoice with this information.

I created a POST request with the “url” I got from step 1.

Autorization (AWS Signature) is set with AccessKey, SecretKey, Session Token, AWS Region (eu-west-1) and Service Name (“s3” instead of “execute-api”).

Headers contains “Content-Type” as “text/plain” (I aslo tried “application/pdf”).

In the body I tried the following combinations:

form-data
“file” and then added the PDF file

raw
Added base64 encoded PDF file as string

binary
Added the PDF file

It doesn’t matter what configuration I choose, the answer alsways contains:

<Error>
    <Code>SignatureDoesNotMatch</Code>
    <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

I have contacted Amazon Support about this, but they are not helpful at all, they just point me back to the above mentioned documentation.

I have also searched endlessly around to find anyone with the same or a similar problem, but so far nothing I found fits or was even remotely helpful.

Can someone please help me to figure out how I am able to successfully upload a PDF invoice to Amazon using SP-API in Postman?

The developer profile is approved for ALL roles including ALL restricted roles, so this shouldn’t be a problem.

I doubt you will get much of a response without posting some screenshots or your code where you are generating these elements.

1 Like

I am not sure if screenshots will provide any additional information that isn’t mentioned in the original post, but I will try to add more information so that maybe someone is able to help me.

Here are the screenshots of the request:

Params

Authorization


AccessKey, SecretKey and Session Token replaced with a variable for this screenshot.

Headers

{{feedurl}} was used in the screenshots. The real url comes from a create Feed Document request and looks like this:
https://tortuga-prod-eu.s3-eu-west-1.amazonaws.com/%2FNinetyDays/amzn1.tortuga.4.eu.***.***?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221209T170630Z&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Expires=300&X-Amz-Credential=***%2F20221209%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Signature=***

Hidden Headers

Body


The raw part of the Body contains the Base64 String of a PDF file.

If any more information is needed please let me know.

That documentation could do with some example request\responses for each step.

Pretty sure that the Base64 string for the PDF file is only part of the file.

There is an example hidden away on the right for Java that might be of use.
upload-sample-code-java

However, I don’t think that is your current issue.

It’s complaining about the authentication so I suspect the issues likes with one of the following.

AccessKey , SecretKey or Session Token

The documentation desperately needs a revision and definitely needs examples for each step.

The Base64 string I have represents the complete PDF file.
You can convert the PDF file to a Base64 string and the Base64 string back to a PDF file.

I have tried working with the Java Code, but since I want to send out a raw request the code doesn’t help me out here.

AccessKey, SecretKey and Session Token work fine with others requests, so I doubt that this is the problem.

I have tried a different configuration for the Body:

The Body now contains the feedTpye, the marketplaceId, the InputFeedDocumentId I got from createFeedDocument, feedOptions and the FeedContent which in this case is the Base64 string of the PDF file.

When I execute the request now I get the following response:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>SignatureDoesNotMatch</Code>
    <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
(...)

It is basically the same error as I’ve gotten before.

I have absolutely no idea what the problem is and how I could fix it.