double-break / spapi-php

Amazon Selling Partner API PHP Client
MIT License
56 stars 46 forks source link

ResultMessageCode 5001 XML Parsing Fatal Error Content is not allowed in trailing section. Content is not allowed in trailing section #877 #33

Closed aniruddhaad closed 2 years ago

aniruddhaad commented 3 years ago

Create a product feed feedType "POST_PRODUCT_DATA" create feed document id upload feed create feed -> get feed id getFeed using feed id if processingStatus is DONE then get Feed Document then download Feed Processing Report I always getting ResultMessageCode 5001 ResultDescription XML Parsing Fatal Error at Line 27, Column 1: Content is not allowed in trailing section. Content is not allowed in trailing section

Confirmed that file is utf-8 encoded. Same is mentioned in xml encoding declaration. Tried setting DocumentVersion 1.01 and 1.02. No difference. Same error.

URL of the content on GitHub 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

Description of what the documentation currently says Step 6. Download and decrypt the feed processing report You can download and decrypt the feed processing report using the information returned in the previous step.

Description of what the documentation should say It should say the error codes and error messages to expect. There is no error code documented. There is no feed specifciations. The exact feed is working with MWS but not working with new API.

From the other ticket I created with https://github.com/amzn/selling-partner-api-models/issues/1473 Here is further information -

  1. I converted encoding to UTF-8 using notepad++ (it was already converted using php script using mb_convert but just to make sure.). Also opened file in editplus and used Hex Viewer to make sure there is nothing after last tag. Also the same feed works with MWS without manually converting anything. As this is working in production and same item was already live on amazon. And moreover I opened XML file in VIM deleted last tag and typed it by hand again and saved it. However I am still getting the same error.

  2. Someone suggested - document invalid error <?xml version="1.0"?>

if you put a space between " and ? symbols, it should work. <?xml version="1.0" ?>

So i have also tried that too. See the attached feed.

split-amazon-products-1 (2).txt

So back to square one. Can someone please check this?

aniruddhaad commented 3 years ago

Any thoughts/suggestions? anyone?

aniruddhaad commented 3 years ago

Finally I found the bug. ASECryptoStream.php public static function encrypt(string $plainText, string $key, string $iv): string replace line (line number 71) - $plainText = static::getPaddedText($plainText); with $plainText = trim(static::getPaddedText($plainText)); and it starts working

AisxLee commented 3 years ago

Finally I found the bug. ASECryptoStream.php public static function encrypt(string $plainText, string $key, string $iv): string replace line (line number 71) - $plainText = static::getPaddedText($plainText); with $plainText = trim(static::getPaddedText($plainText)); and it starts working

Thanks for sharing

yaniv-sellersnap commented 2 years ago

@aniruddhaad just wanted to say thank you, I encountered the exact same issue and your solution worked for me. Thanks!