Search code examples
c#asp.net-core-webapi.net-8.0amazon-selling-partner-api

Amazon sp-api ConfirmShipment does not set "Delivery Service"


I am using Amazon sp-api and confirming the Tracking Number like below:

public bool UpdateTrackingNumber(DtoShipment dto)
{
    ConfirmShipmentOrderItemsList orderItems = new ConfirmShipmentOrderItemsList();
    foreach (OrderItem item in dto.LstOrderItem)
    {
        orderItems.Add(new ConfirmShipmentOrderItem(item.OrderItemId, item.Quantity));
    }
    ConfirmShipmentRequest confirmShipmentRequest = new ConfirmShipmentRequest()
    {
        MarketplaceId = getMarketPlaceId(dto.CountryCode),
        PackageDetail = new PackageDetail()
        {
            TrackingNumber = dto.TrackingNumber,
            CarrierName = dto.CarrierName,  // "DPD Home 0-31.5kg"
            CarrierCode = dto.CarrierCode,  // "DPD"
            PackageReferenceId = "1",
            ShipDate = DateTime.UtcNow,
            OrderItems = orderItems
        }
    };
    AmazonConnection _connAmazon = createAmazonConnection("marketplaceId");
    return _connAmazon.Orders.ConfirmShipment(dto.AmazonOrderId, confirmShipmentRequest);
}

It sets the Tracking Number successfully, but the "Delivery Service" field stays empty. I am not sure that was a problem or not, but I am wondering if it is possible to set that value also with this method?

Edit: When I set the tracking number by using Amazon interface, "DPD" is automatically selected for "Carrier" and "Other" is automatically selected for "Delivery Service" and "DPD Home 0-31.5kg" is under that.

Edit 2: When I set via API, Tracking Number and Carrier have been set, but "Delivery Service" is not." enter image description here

If I use Amazon interface, Amazon brings me all fields filled like that. I only write the "Tracking Number" and confirm shipment. enter image description here

Edit 3: Thanks @Charlieface, It worked like that:

            PackageDetail = new PackageDetail()
            {
                TrackingNumber = dto.TrackingNumber,
                CarrierName = "",
                CarrierCode = dto.CarrierCode,  // "DPD"
                PackageReferenceId = "1",
                ShipDate = DateTime.UtcNow,
                OrderItems = orderItems,
                ShippingMethod = dto.CarrierName  // "DPD Home 0-31.5kg"
            }

Thanks in advance.


Solution

  • The documentation indicates a shippingMethod property.

    Name Description Schema
    carrierCode required Identifies the carrier that will deliver the package. This field is required for all marketplaces, see reference. string
    carrierName optional Carrier Name that will deliver the package. Required when carrierCode is "Others" string
    shippingMethod optional Ship method to be used for shipping the order. string

    Process of elimination leads to this property being the one used for the "Delivery Srevice", and that is what we have found works.