Json UPS运价估算API-测试链接错误

Json UPS运价估算API-测试链接错误,json,rest,api,ups,Json,Rest,Api,Ups,我一直在使用upsapi来获取包的速率估计,并且可以在普通包上使用JSON来实现这一点,并使用链接获得良好的响应 我还想使用运费估算,并实现了一个直接取自开发人员文档的格式良好的请求。我使用的链接方式完全相同,但包含运费选项。 这些都是测试链接。当我使用货运请求时,返回的错误如下: { "Fault":{ "faultcode":"Client", "faultstring":"An exception has been raised as a result of

我一直在使用upsapi来获取包的速率估计,并且可以在普通包上使用JSON来实现这一点,并使用链接获得良好的响应

我还想使用运费估算,并实现了一个直接取自开发人员文档的格式良好的请求。我使用的链接方式完全相同,但包含运费选项。

这些都是测试链接。当我使用货运请求时,返回的错误如下:

{
   "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": ""

        }

    }

因此,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":""
         }
      }
   }
}