I am trying to setup UPS XML method for Shipping Rates, and it seems to work for any address in California. When I try an address outside of California, I do not get any shipping rates back.

enter image description here

So I looked at the Magento debug.log and saw the below response. My assumption is that it is replacing the StateProvinceCode for CA when its sending the request to UPS.

I looked at the following link https://github.com/magento/magento2/issues/6875 thinking the issue could be fixed, but its still ignoring the region in the Shipping Method.

'accessRequest' => '<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
  'request' => '<?xml version="1.0"?>
<RatingServiceSelectionRequest xml:lang="en-US">
      <CustomerContext>Rating and Service</CustomerContext>
          <Description>Customer Counter</Description>

  <Shipment>      <Shipper>      <Address>
          <StateProvinceCode>CA</StateProvinceCode><ResidentialAddressIndicator>01</ResidentialAddressIndicator>      </Address>


    </Package>  </Shipment>
  'result' => '<?xml version="1.0"?>
<RatingServiceSelectionResponse><Response><TransactionReference><CustomerContext>Rating and Service</CustomerContext><XpciVersion>1.0</XpciVersion></TransactionReference><ResponseStatusCode>0</ResponseStatusCode><ResponseStatusDescription>Failure</ResponseStatusDescription><Error><ErrorSeverity>Hard</ErrorSeverity><ErrorCode>111285</ErrorCode><ErrorDescription>The postal code 28607 is invalid for CA United States.</ErrorDescription></Error></Response></RatingServiceSelectionResponse>
  • Faced same issue with DHL. It's missing <City></City> as it's required. So u need to override & Pass City then it works – Ankit Shah Mar 24 '17 at 1:24
  • 1
    magento\vendor\magento\module-ups\Model\Carrier.php Check for setRequest function weather it's setting city or not – Ankit Shah Mar 24 '17 at 1:36
  • It is not a City problem here but a wrong region code. Should be NC and note CA – Franck Garnier Mar 27 '17 at 8:42

After more debugging and google searching. I came across this commit in the Magento 2 project: https://github.com/magento/magento2/commit/e788a2421f5cfe2df9d5028b08141d92f70819b8

It details javascript changes that need to occur in three files. This fix has not yet been included in any Magento Release and the changes should not be done in the core files. Instead as a temporary solution until the solution is released, I basically overwrote these files in my theme directory (app/design/frontend/{Vendor}/{Theme}/Magento_Checkout/web/js/model/ directory.

The following modifications have been made to the files:



Theme Directory:


The formAddressDataToQuoteAddress() needs modifications` as so:

formAddressDataToQuoteAddress: function(formData) {
            // clone address form data to new object
            var addressData = $.extend(true, {}, formData),
                regionName = addressData.region;
            if (mageUtils.isObject(addressData.street)) {
                addressData.street = this.objectToArray(addressData.street);

            addressData.region = {
                region_id: addressData.regionId,
                region_code: addressData.regionCode,
                region: regionName

            if (addressData.region_id
                && countryData()[addressData.country_id]
                && countryData()[addressData.country_id]['regions']
            ) {
                region = countryData()[addressData.country_id]['regions'][addressData.region_id];
                if (region) {
                    addressData.region.region_id = addressData['region_id'];
                    addressData.region.region_code = region['code'];
                    addressData.region.region = region['name'];
                } else if (
                    && countryData()[addressData.country_id]
                    && countryData()[addressData.country_id]['regions']
                ) {
                    addressData.region_code = '';
                    addressData.region.region = '';
            delete addressData.region_id;

            return address(addressData);



Theme Directory:


The changes in the new-customer-address.js file depends on the version of Magento 2 you are running. It seemed the fix in github dates back to September 28, 2016. My Magento version is 2.1.3. So I had to do a few more modifications to the file for it to work as detailed in the following snippet.

return function (addressData) {
        var identifier = Date.now();

        var regionId = null;

        if (addressData.region && addressData.region.region_id) {
            regionId = addressData.region.region_id;
        } else if (addressData.country_id && addressData.country_id == window.checkoutConfig.defaultCountryId) {
            regionId = window.checkoutConfig.defaultRegionId;

        return {
            email: addressData.email,
            countryId: (addressData.country_id) ? addressData.country_id : window.checkoutConfig.defaultCountryId,
            regionId: regionId || addressData.regionId,



Theme Directory:


Finally the validateFields() method is modified:

validateFields: function () {
            var addressFlat = addressConverter.formDataProviderToFlatData(

            if (this.validateAddressData(addressFlat)) {
                addressFlat = uiRegistry.get('checkoutProvider').shippingAddress;
                address = addressConverter.formAddressDataToQuoteAddress(addressFlat);

If you check the UPS XML response, you have the error message which describe your problem.

Error code: 111285

ErrorDescription: The postal code 28607 is invalid for CA United States.

The region code should be NC.

Moreorver, in my environement, I should apply this fix to make UPS working with Magento 2 : https://github.com/magento/magento2/issues/6875

Overwide app/design/frontend/{Vendor}/{Theme}/Magento_Checkout/web/js/model/address-converter.js

In the formAddressDataToQuoteAddress JS function, update this code :

        // Update regionId and regionCode typo in order to send correct code to UPS
        addressData.region = {
            region_id: addressData.regionId,
            region_code: addressData.regionCode,
            region: regionName
        // END OVERWRIDE

And make sure to use the latest Magento 2.1.5

EDIT: I reproduce a similar problem even with this fix. It seems that the region_id is not updated on the frontend side. I keep you updated if I find the cause.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.