首页 > 解决方案 > UPS 运输 REST API

问题描述

我想使用 UPS 的 API 进行虚拟 REST 调用,以生成测试假装运请求。

我正在关注运输包裹的 REST UPS 文档:

https://www.ups.com/upsdeveloperkit/downloadresource?loc=en_US

第 116 页显示了一个客户端应用程序示例,该客户端应用程序创建了一个货件并获得了一个带有运输标签的成功响应。我想重新创建它,所以我尝试将一些假数据发布到 TEST URL 地址:

https://wwwcie.ups.com/ship/v1/shipments

我提出了请求(带有标头和正文信息),但我不断收到错误代码 120100(缺少或无效的托运人编号)。

很多论坛帖子都说这与我的地址没有在我的 UPS 帐户上设置有关,但我的帐户上已经设置了地址,我只想向 TEST URL 端点发出虚假请求。

这是请求的正文:

{
"ShipmentRequest":{
"Shipment":{ "Description":"1206 PTR", "Shipper":{
"Name":"ShipperName", "AttentionName":"AttentionName", "TaxIdentificationNumber":"TaxID", "Phone":{
"Number":"1234567890" },
"ShipperNumber":"ShipperNumber", "Address":{
"AddressLine":"AddressLine", "City":"City", "StateProvinceCode":"STD", "PostalCode":"PostalCode", "CountryCode":"EN"
} },
"ShipTo":{
"Name":"ShipToName", "AttentionName":"AttentionName", "Phone":{
"Number":"1234567890" },
"FaxNumber":"1234567999", "TaxIdentificationNumber":"456999", "Address":{
"AddressLine":"AddressLine", "City":"City", "StateProvinceCode":"STD", "PostalCode":"PostalCode", "CountryCode":"EN"
} },
"ShipFrom":{ "Name":"ShipperName", "AttentionName":"AttentionName", "Phone":{
"Number":"1234567890" },
"FaxNumber":"1234567999", "TaxIdentificationNumber":"456999", "Address":{
"AddressLine":"AddressLine", "City":"City",
"StateProvinceCode":"STD", "PostalCode":"PsotalCode", "CountryCode":"EN"
} },
"PaymentInformation":{ "ShipmentCharge":{
"Type":"01", "BillShipper":{
"AccountNumber":"AccountNumber" }
} },
"Service":{
"Code":"01", "Description":"Expedited"
},
"Package":[{ "Description":"International Goods", "Packaging":{
"Code":"02" },
"PackageWeight":{ "UnitOfMeasurement":{
"Code":"LBS" },
"Weight":"10" },
"PackageServiceOptions":"" },
{
"Description":"International Goods", "Packaging":{
"Code":"02" },
"PackageWeight":{ "UnitOfMeasurement":{
"Code":"LBS" },
"Weight":"20" },
"PackageServiceOptions":"" }]
, "ItemizedChargesRequestedIndicator":"", "RatingMethodRequestedIndicator":"", "TaxInformationIndicator":"", "ShipmentRatingOptions":{
"NegotiatedRatesIndicator":"" }
}, "LabelSpecification":{
"LabelImageFormat":{ "Code":"GIF"
} }
} }

标签: apirestrestful-urlshippingups

解决方案


我通过查找链接到 UPS 开发人员帐户的发件人编号(帐号)解决了此问题。


推荐阅读