Search code examples
node.jsamazon-mws

Error with signature when creating an outbound shipment on Amazon MWS API


I'm trying to create an outbound fulfillment (CreateFulfillmentOrder) on the Amazon MWS API. I'm using the node.js package mws-api to make the request, which I have modified myself since it didn't support this operation correctly. In any case, this is the exact request that I'm sending to the API (with sensitive information changed):

{ 
 uri: 'https://mws.amazonservices.co.uk/FulfillmentOutboundShipment/2010-10-01',
 method: 'POST',
 headers:
  { Host: 'mws.amazonservices.co.uk',
    'User-Agent': 'mws-api/0.1.0 (Language=JavaScript)',
    'content-type': 'application/x-www-form-urlencoded',
    'content-length': 1095 },
 body: 'SellerFulfillmentOrderId=403-9883411-3564317&ShippingSpeedCategory=Standard&DisplayableOrderId=403-9883411-3564317&DisplayableOrderDateTime=2013-12-29&DisplayableOrderComment=Order&NotificationEmailList.member.1=3yv4at7rtl3blsy%40marketplace.amazon.co.uk&DestinationAddress.Name=Amazon%20Taro&DestinationAddress.Line1=COMPANY%NAME&DestinationAddress.City=GORING&DestinationAddress.StateOrProvinceCode=Oxon&DestinationAddress.PostalCode=RG8%209AQ&DestinationAddress.CountryCode=GB&DestinationAddress.PhoneNumber=01575375219&Items.member.1.DisplayableComment=item&Items.member.1.GiftMessage=gift&Items.member.1.PerUnitDeclaredValue.Value=4.29&Items.member.1.PerUnitDeclaredValue.CurrencyCode=GBP&Items.member.1.Quantity=1&Items.member.1.SellerFulfillmentOrderItemId=CW0298&Items.member.1.SellerSKU=CW0298&Action=CreateFulfillmentOrder&Version=2010-10-01&Timestamp=2017-04-12T14%3A39%3A22.707Z&AWSAccessKeyId=LYIAJ83AORVSI6WLBTQA&SellerId=7RVB74LQNDFDB1&SignatureMethod=HmacSHA256&SignatureVersion=2&Signature=nlB5UTDUXexkurlsc7e%2F4tqLO8vcMRy4X%6Oa0rPIapZN8%3D' }

But all I'm getting in response is this error:

The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

I don't there's any problem with the signature, it has worked correctly while doing other operations. I think that's just the error Amazon gives you when something's wrong on the request, but I cannot find the problem. Does anyone know what could be the problem?

Thanks.


Solution

  • You need to use Amazon Host mws.amazonaws.com.

    Ex:

        { 
         uri: 'https://mws.amazonaws.com/FulfillmentOutboundShipment/2010-10-01',
         method: 'POST',
         headers:
          { Host: 'mws.amazonaws.com',
                'User-Agent': 'mws-api/0.1.0 (Language=JavaScript)',
                'content-type': 'application/x-www-form-urlencoded',
            'content-length': 1095 
           },
           body:'SellerFulfillmentOrderId=403-9883411-3564317&ShippingSpeedCategory=Standard&DisplayableOrderId=403-9883411-3564317&DisplayableOrderDateTime=2013-12-29&DisplayableOrderComment=Order&NotificationEmailList.member.1=3yv4at7rtl3blsy%40marketplace.amazon.co.uk&DestinationAddress.Name=Amazon%20Taro&DestinationAddress.Line1=COMPANY%NAME&DestinationAddress.City=GORING&DestinationAddress.StateOrProvinceCode=Oxon&DestinationAddress.PostalCode=RG8%209AQ&DestinationAddress.CountryCode=GB&DestinationAddress.PhoneNumber=01575375219&Items.member.1.DisplayableComment=item&Items.member.1.GiftMessage=gift&Items.member.1.PerUnitDeclaredValue.Value=4.29&Items.member.1.PerUnitDeclaredValue.CurrencyCode=GBP&Items.member.1.Quantity=1&Items.member.1.SellerFulfillmentOrderItemId=CW0298&Items.member.1.SellerSKU=CW0298&Action=CreateFulfillmentOrder&Version=2010-10-01&Timestamp=2017-04-12T14%3A39%3A22.707Z&AWSAccessKeyId=LYIAJ83AORVSI6WLBTQA&SellerId=7RVB74LQNDFDB1&SignatureMethod=HmacSHA256&SignatureVersion=2&Signature=nlB5UTDUXexkurlsc7e%2F4tqLO8vcMRy4X%6Oa0rPIapZN8%3D' 
        }
    

    This may help you.