api - 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"
} }
} }
解决方案
我通过查找链接到 UPS 开发人员帐户的发件人编号(帐号)解决了此问题。
推荐阅读
- r - 创建一个表,其中包含列数、行数、行中的 NA 数、列表中的数据帧数
- sql - 对 COUNT 和 GROUP BY statemetns 的输出进行数学运算
- php - $_SESSION 变量未设置
- security - Firefox 显示 phpMyAdmin 的“连接不安全”。为什么我在 URL 中看不到 https://?
- mysql - 选择中另一个表的Mysql JSON_ARRAYAGG
- php - 为什么下面的 PHP cURL 代码没有发布任何数据?
- xml - 对 Oracle 数据库运行 Liquibase GenerateChangeLog 命令导致空闲,在特定点之后日志文件/控制台中没有输出
- android - HttpsURLConnection, SSLPeerUnverifiedException 访问 IP 地址时发生
- airflow - Apache Airflow 问题 - “具有 task_id create_tag_template_field_result 的任务已经在 DAG 中”
- c# - HTMLAgilityPack 没有加载网页的 html