Skip to content

UPS - UseNegotiatedRates not working because of StateProvinceCode #80

@elcapitanandres

Description

@elcapitanandres

When use UPS and UseNegotiatedRates = true with valid account and ShipperNumber, the server response doesn't contains the "NegotiatedRates" node. In the response details there is a Warning node "RatedShipmentWarning" = Invalid Origin State/Province.
Current code is not setting the Shipper province as you can see:

writer.WriteStartElement("Address");
writer.WriteElementString("PostalCode", Shipment.OriginAddress.PostalCode);
writer.WriteElementString("CountryCode", Shipment.OriginAddress.CountryCode);
writer.WriteEndElement(); // </Address>

Seems UPS needs the StateProvinceCode node in the Shipper Address if UseNegotiatedRates=true
If change code to:

writer.WriteStartElement("Address");
writer.WriteElementString("PostalCode", Shipment.OriginAddress.PostalCode);
writer.WriteElementString("CountryCode", Shipment.OriginAddress.CountryCode);
if (!string.IsNullOrWhiteSpace(Shipment.OriginAddress.State))//<RatedShipmentWarning>Invalid Origin State/Province</RatedShipmentWarning>
{
	writer.WriteElementString("StateProvinceCode", Shipment.OriginAddress.State);
}
writer.WriteEndElement(); // </Address>

I receive the NegotiatedRates node completed.
There is any reason why the origin "StateProvinceCode" is not set?
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions