API оценки скорости фрахта UPS - ошибка с тестовой ссылкой - PullRequest
0 голосов
/ 06 ноября 2019

Я использую API UPS для получения оценок тарифов на пакеты, и могу сделать это с JSON для обычных пакетов и получить хороший ответ, используя ссылку https://wwwcie.ups.com/rest/Rate

Я хочу использовать оценки тарифов на перевозкуа также реализовали правильно сформированный запрос, взятый непосредственно из документации разработчика. Ссылка, которую я использую, точно такая же, но с включенными опциями фрахта. https://wwwcie.ups.com/rest/FreightRate

Это обе тестовые ссылки. Когда я использую запрос на перевозку, я получаю сообщение об ошибке:

{
   "Fault":{
      "faultcode":"Client",
      "faultstring":"An exception has been raised as a result of client data.",
      "detail":{
         "Errors":{
            "ErrorDetail":{
               "Severity":"Hard",
               "PrimaryErrorCode":{
                  "Code":"10002",
                  "Description":"The XML document is well formed but the document is not valid"
               }
            }
         }
      }
   }
}

Чтобы получить представление о том, что я отправляю (опять же, непосредственно скопировано из документации разработчика), это то, что запрос выглядиткак

{
        "UPSSecurity": {
            "UsernameToken": {
                "Username": "myName",
                "Password": "thePassword"
            },
            "ServiceAccessToken": {
                "AccessLicenseNumber": "RemovedForStackOverflowButItIsCorrect"
            }
        },
        "FreightRateRequest": {
            "ShipFrom": {
                "Name": "Test US Shipper",
                "Address": {
                    "AddressLine": "123 Lane",
                    "City": "TIMONIUM",
                    "StateProvinceCode": "MD",
                    "PostalCode": "21093",
                    "CountryCode": "US",
                    "ResidentialAddressIndicator": ""
                },
                "AttentionName": "Test Shipper",
                "Phone": {
                    "Number": "4444444444",
                    "Extension": "4444"
                },
                "EMailAddress": "gcc0htq@ups.com"
            },
            "ShipperNumber": "AT0123",
            "ShipTo": {
                "Name": "Dilbert\u0027s Derbies",
                "Address": {
                    "AddressLine": "555 Main St",
                    "City": "LOUISVILLE",
                    "StateProvinceCode": "KY",
                    "PostalCode": "40201",
                    "CountryCode": "US"

                },
                "AttentionName": "Dilbert",
                "Phone": {
                    "Number": "8459865555"

                }

            },
            "PaymentInformation": {
                "Payer": {
                    "Name": "Test US Shipper",
                    "Address": {
                        "AddressLine": "123 Lane",
                        "City": "LUTHERVILLE TIMONIUM",
                        "StateProvinceCode": "MD",
                        "PostalCode": "21093",
                        "CountryCode": "US"
                    },
                    "ShipperNumber": "AT0123",
                    "AccountType": "1",
                    "AttentionName": "Test Shipper",
                    "Phone": {
                        "Number": "4444444444",
                        "Extension": "4444"
                    },
                    "EMailAddress": "gcc0htq@ups.com"
                },
                "ShipmentBillingOption": {
                    "Code": "10"

                }

            },
            "Service": {
                "Code": "308"
            },
            "Commodity": {
                "Description": "FRS-Freight",
                "Weight": {
                    "UnitOfMeasurement": {
                        "Code": "LBS"
                    },
                    "Value": "150"

                },
                "Dimensions": {
                    "UnitOfMeasurement": {
                        "Code": "IN",
                        "Description": " "
                    },
                    "Length": "9",
                    "Width": "5",
                    "Height": "4"
                },
                "NumberOfPieces": "1",
                "PackagingType": {
                    "Code": "PLT"
                },
                "FreightClass": "60"

            },
            "DensityEligibleIndicator": "",
            "AlternateRateOptions": {
                "Code": "3"
            },
            "PickupRequest": {
                "PickupDate": "20191123"
            },
            "GFPOptions": {
                "GPFAccesorialRateIndicator": ""
            },
            "TimeInTransitIndicator": ""

        }

    }

1 Ответ

0 голосов
/ 06 ноября 2019

Получается, что документ API устарел, после обращения в UPS они дали мне информацию относительно требуемой структуры. Это так:

{
   "UPSSecurity":{
      "UsernameToken":{
         "Username":"Username",
         "Password":"Password"
      },
      "ServiceAccessToken":{
         "AccessLicenseNumber":"AccessLicenseNumber"
      }
   },
   "FreightRateRequest":{
      "Request":{
         "RequestOption":"1",
         "TransactionReference":{
            "TransactionIdentifier":"TransactionIdentifier"
         }
      },
      "ShipFrom":{
         "Name":"ShipFrom Name",
         "Address":{
            "AddressLine":"AddressLine",
            "City":"City",
            "StateProvinceCode":"StateProvinceCode",
            "PostalCode":"PostalCode",
            "CountryCode":"CountryCode"
         },
         "AttentionName":"Contact",
         "Phone":{
            "Number":"Phone number",
            "Extension":"Extension number"
         },
         "EMailAddress":"EMailAddress"
      },
      "ShipperNumber":"ShipperNumber",
      "ShipTo":{
         "Name":"ShipTo name",
         "Address":{
            "AddressLine":"AddressLine",
            "City":"City",
            "StateProvinceCode":"StateProvinceCode",
            "PostalCode":"PostalCode",
            "CountryCode":"CountryCode"
         },
         "AttentionName":"AttentionName",
         "Phone":{
            "Number":"Phone number",
            "Extension":"Extension number"
         }
      },
      "PaymentInformation":{
         "Payer":{
            "Name":"Payer Name",
            "Address":{
               "AddressLine":"AddressLine",
               "City":"City",
               "StateProvinceCode":"StateProvinceCode",
               "PostalCode":"PostalCode",
               "CountryCode":"CountryCode"
            },
            "ShipperNumber":"Payer\u0027s shipper Number",
            "AccountType":"AccountType",
            "AttentionName":"AttentionName",
            "Phone":{
               "Number":"Phone number",
               "Extension":"Extension number"
            },
            "EMailAddress":"EMailAddress"
         },
         "ShipmentBillingOption":{
            "Code":"ShipmentBillingOption"
         }
      },
      "Service":{
         "Code":"Service code"
      },
      "HandlingUnitOne":{
         "Quantity":"HandlingUnitOne quantity",
         "Type":{
            "Code":"HandlingUnitOne code"
         }
      },
      "Commodity":{
         "Description":"Commodity description",
         "Weight":{
            "UnitOfMeasurement":{
               "Code":"UnitOfMeasurement code"
            },
            "Value":"Weight"
         },
         "NumberOfPieces":"NumberOfPieces",
         "PackagingType":{
            "Code":"PackagingType code"
         },
         "FreightClass":"FreightClass"
      },
      "ShipmentServiceOption":{
         "WeekendPickupIndicator":""
      },
      "DensityEligibleIndicator":"",
      "AdjustedWeightIndicator":"",
      "HandlingUnitWeight":{
         "Value":"HandlingUnitWeight",
         "UnitOfMeasurement":{
            "Code":"UnitOfMeasurement code"
         }
      },
      "AlternateRateOptions":{
         "Code":"AlternateRateOptions code"
      },
      "PickupRequest":{
         "PickupDate":"PickupDate"
      },
      "TimeInTransitIndicator":"",
      "GFPOptions":{
         "OnCallInformation":{
            "OnCallPickupIndicator":""
         }
      }
   }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...