amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
611 stars 733 forks source link

SP-API Invoice File is corrupted when downloading from Amazon #1715

Closed sh123-987 closed 3 years ago

sh123-987 commented 3 years ago

Hi,

So I couldn't find any documentation which explains how to upload invoice files for orders on Amazon. The only documentation can be found here (which is for MWS not for SP-API): https://m.media-amazon.com/images/G/03/B2B/invoice-uploader-developer-documentation.pdf

A user @fernlop from this forum does state he was able to upload the invoice file successfully: https://github.com/amzn/selling-partner-api-models/issues/1158

I tried following his steps, my code is able to upload the invoice file for an order successfully. When I also use the Feeds Report it's telling me Amazon has successfully processed the file i've sent them successfully. Number of records processed 1 Number of records successful 1

But when I check the orders on Amazon's Seller portal and try to download the invoice file from there I get this error: Error: Failed to load PDF document.

I suspect it must be to do with my code to upload the pdf file contents to the url amazon's api returns: I'm currently using this code from the documentation here, it works fine for submiting feeds to create new listing, update price/stock etc. But doesn't appear to work for uploading pdf files. https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/feeds-api-use-case-guide/feeds-api-use-case-guide-2020-09-04.md#encrypt-and-upload-sample-code-java

gaurav-webs commented 3 years ago

@sh123-987 As per this announcement https://github.com/amzn/selling-partner-api-docs/discussions/1107, the encryption and decryption of the file are removed in the new version (2021-06-30) in the feed and report API.

here is the new version upload feed code.

so you can easily download and upload the document without encryption and decryption, you can find the new Use Case Guide and API Reference on the above announcement.

sh123-987 commented 3 years ago

@sh123-987 As per this announcement #1107, the encryption and decryption of the file are removed in the new version (2021-06-30) in the feed and report API.

here is the new version upload feed code.

so you can easily download and upload the document without encryption and decryption, you can find the new Use Case Guide and API Reference on the above announcement.

Sorry for late reply forgot to reply to this. But yeah using the newer version worked for me. The removal of the encryption and decryption got my code to work and now the invoice files appear fine on Amazon's portal. Thanks