keithbrink / amazon-mws-laravel

A Laravel library for Amazon's MWS web services, supporting Laravel 5-8+
Apache License 2.0
27 stars 23 forks source link

Bad Response! 400 Bad Request: MalformedInput #9

Closed michaeln-recommerce closed 4 years ago

michaeln-recommerce commented 5 years ago

Could you please identify and help resolve issue. :-) I am receiving the following entries in Laravel log file:

local.INFO: Making request to Amazon: ListOrders
local.ERROR: Bad Response! 400 Bad Request: MalformedInput - Start of list found where not expected

Using MWS Scratch Pad I receive a response. Here is the request:

POST 
https://mws.amazonservices.com/Orders/2013-09-01
    ?AWSAccessKeyId=___________
    &Action=ListOrders
    &SellerId=___________
    &SignatureVersion=2
    &Timestamp=2019-05-07T00%3A45%3A35Z
    &Version=2013-09-01
    &Signature=J4apOvpj2vEBwbWSUjI9QK66jlBzVXr5nSxRBJ%2FwYIo%3D
    &SignatureMethod=HmacSHA256
    &CreatedAfter=2019-05-05T04%3A00%3A00Z
    &MarketplaceId.Id.1=___________ 

POST
https:/mws.amazonservices.com/Orders/2013-09-01
    ?AWSAccessKeyId=___________
    &Action=ListOrders
    &CreatedAfter=2019-05-05T04%3A00%3A00Z
    &MarketplaceId.Id.1=___________ 
    &SellerId=___________
    &SignatureMethod=HmacSHA256
    &SignatureVersion=2
    &Timestamp=2019-05-07T00%3A45%3A35Z
    &Version=2013-09-01

I added some debug output in this Laravel package and here is what was requested and received:

https://mws.amazonservices.com/Orders/2013-09-01
?SellerId=A32GOXAC8X4KTS
    &MarketplaceId=___________
    &AWSAccessKeyId=___________
    &SignatureVersion=2
    &SignatureMethod=HmacSHA256
    &Version=2013-09-01
    &MarketplaceId.Id.1=___________
    &CreatedAfter=2019-05-07T14%3A35%3A07%2B0000
    &CreatedBefore=2019-05-07T14%3A35%3A07%2B0000
    &Action=ListOrders
    &Timestamp=2019-05-07T14%3A37%3A07%2B0000
    &Signature=RABLuc9zbUfVS%2Bd1KTAM0KI78GwZAkQ2%2BMRrAyn5lrc%3D

$response = Array
(
    [head] => HTTP/1.1 400 Bad Request
Server: Server
Date: Tue, 07 May 2019 14:39:07 GMT
Content-Type: text/xml
Content-Length: 313
Connection: keep-alive
X-Amz-Date: Tue, 07 May 2019 14:39:07 GMT
x-amzn-Authorization: AAA identity=com.amazon.aaa.MarketplaceWebServiceOrders.AndromedaControlService.amzn1.aaa.id.qhz3ylg755gkejyk5sh44qm3wy.Default/1, Operation=ListOrders, Service=MarketplaceWebServiceOrders, Encrypted=false, SignedHeaders=X-Amz-Date, Algorithm=HmacSHA256, Signed=true, Signature=rNH4WQiPPSZ4noiOg9qZn5QS5SR9Hol8fqht+hjqe7c=,RelationshipVersion=0
x-mws-request-id: 671757e2-74c1-42a0-99a4-41d84e190f9d
x-mws-timestamp: 2019-05-07T14:39:07.758Z
x-mws-response-context: cTNVd7MCoLKdq3+Pqlv0OprCVCCaEUoAly9aTH4DWjGCybuyhQgKHMqshjXQsh8RiQk0UMHA0ME=
x-amz-rid: HDENRW2FR3X8TMBV7CRN
Vary: Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent
    [body] => <?xml version="1.0"?>
<ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
  <Error>
    <Type>Sender</Type>
    <Code>MalformedInput</Code>
    <Message>Start of list found where not expected</Message>
  </Error>
  <RequestId>671757e2-74c1-42a0-99a4-41d84e190f9d</RequestId>
</ErrorResponse>

    [code] => 400
    [answer] => Bad Request
    [error] => Bad Request
    [ok] => 0
    [headarray] => Array
        (
            [Server] => Server
            [Date] => Tue, 07 May 2019 14:39:07 GMT
            [Content-Type] => text/xml
            [Content-Length] => 313
            [Connection] => keep-alive
            [X-Amz-Date] => Tue, 07 May 2019 14:39:07 GMT
            [x-amzn-Authorization] => AAA identity=com.amazon.aaa.MarketplaceWebServiceOrders.AndromedaControlService.amzn1.aaa.id.qhz3ylg755gkejyk5sh44qm3wy.Default/1, Operation=ListOrders, Service=MarketplaceWebServiceOrders, Encrypted=false, SignedHeaders=X-Amz-Date, Algorithm=HmacSHA256, Signed=true, Signature=rNH4WQiPPSZ4noiOg9qZn5QS5SR9Hol8fqht+hjqe7c=,RelationshipVersion=0
            [x-mws-request-id] => 671757e2-74c1-42a0-99a4-41d84e190f9d
            [x-mws-timestamp] => 2019-05-07T14:39:07.758Z
            [x-mws-response-context] => cTNVd7MCoLKdq3+Pqlv0OprCVCCaEUoAly9aTH4DWjGCybuyhQgKHMqshjXQsh8RiQk0UMHA0ME=
            [x-amz-rid] => HDENRW2FR3X8TMBV7CRN
            [Vary] => Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent
        )

)
michaeln-recommerce commented 5 years ago

What appeared interested and might be related to the bad response-- there is a difference between query parameter names and which parameters were sent using Scratch Pad and this package. Does that package need to be updated? Is there a different end point that needs to be used with our MWS credentials?

michaeln-recommerce commented 5 years ago

This appears to be relevant...is merge needed?

https://github.com/CPIGroup/phpAmazonMWS/issues/153#issuecomment-371063810

keithbrink commented 4 years ago

@michaeln-recommerce Just pushed out a fix for this, as well as Laravel 7 support. If you're still on 6 or lower, you can update to version 5.0.1, or if you're on Laravel 7, update to 7.0.0. Thanks for reporting!