我一直在使用UPS api来获取包裹的费用估算值,并且可以使用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","CountryCode": "US"
},"accountType": "1","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": ""
}
}