【发布时间】:2016-09-06 09:44:47
【问题描述】:
我收到“FedEx Ship 错误:(8522) 包裹数超过最大值”错误。我正在尝试向 fedEX 发送多包裹运输请求,但仅在第一个包裹请求中失败。
对于向 FedEX 发送多个发货请求,我们必须为每个包裹发送单独的请求,主跟踪信息将从请求的第一个包裹作为回复返回。然后将该主跟踪信息插入到针对该多包裹装运请求的每个附加包裹的请求中。
下面的例子是第一次打包请求。
下面是我发送给 FedEX API“https://wsbeta.fedex.com:443/xml”的 XML 请求正文
代码只是准备数据结构,将其转换为 XML 并使用 XML 请求访问 fedEX API。
my $http_request = HTTP::Request->new('POST', $config->{'URL'});
$http_request->content_type('application/x-www-form-urlencoded');
$http_request->content(Encode::encode_utf8($xml_request_body));
my $http_response;
eval {
$http_response = $ua->request($http_request);
};
return errorShipResponse($p) if (!defined $http_response || !$http_response->is_success);
my $response;
eval {
$response = XML::Simple::XMLin(
$http_response->content,
ForceArray => 1,
NSExpand => 1
);
};
$xml_request_body
<?xml version="1.0" encoding="UTF-8"?>
<ProcessShipmentRequest xmlns="http://fedex.com/ws/ship/v12">
<WebAuthenticationDetail>
<UserCredential>
<Key>aaaaaaaaaaa</Key>
<Password>aaaaaaaaaaaaaaaa</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>111111111</AccountNumber>
<MeterNumber>111111111111</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>ship</ServiceId>
<Major>12</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<RequestedShipment>
<ShipTimestamp>2016-09-06T06:42:41-04:00</ShipTimestamp>
<DropoffType>REGULAR_PICKUP</DropoffType>
<ServiceType>SMART_POST</ServiceType>
<PackagingType>YOUR_PACKAGING</PackagingType>
<TotalWeight>
<Units>LB</Units>
<Value>15.00</Value>
</TotalWeight>
<Shipper>
<AccountNumber>111111111111</AccountNumber>
<Tins>
<TinType>BUSINESS_STATE</TinType>
<Number444444444444</Number>
</Tins>
<Contact>
<CompanyName>aaaaaaaaaaaa</CompanyName>
<PhoneNumber>11111111</PhoneNumber>
</Contact>
<Address>
ADDRESS HERE
</Address>
</Shipper>
<Recipient>
<Contact>
<PersonName>mukta jain</PersonName>
<PhoneNumber>1234567899</PhoneNumber>
</Contact>
<Address>
<StreetLines>lwehcfkwdjh</StreetLines>
<City>NY</City>
<StateOrProvinceCode>NY</StateOrProvinceCode>
<PostalCode>12345</PostalCode>
<CountryCode>US</CountryCode>
<Residential>true</Residential>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>444444444</AccountNumber>
<Tins>
<TinType>BUSINESS_STATE</TinType>
<Number>4444444444</Number>
</Tins>
<Contact>
<CompanyName>aaaaaaaaa</CompanyName>
<PhoneNumber>111111111</PhoneNumber>
</Contact>
<Address>
<ADDRESS HERE>
</Address>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<SmartPostDetail>
<Indicia>PARCEL_SELECT</Indicia>
<AncillaryEndorsement>ADDRESS_CORRECTION</AncillaryEndorsement>
<SpecialServices>USPS_DELIVERY_CONFIRMATION</SpecialServices>
<HubId>1234</HubId>
<CustomerManifestId>123456</CustomerManifestId>
</SmartPostDetail>
<LabelSpecification>
<LabelFormatType>COMMON2D</LabelFormatType>
<ImageType>EPL2</ImageType>
<LabelStockType>STOCK_4X6</LabelStockType>
</LabelSpecification>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>3</PackageCount>
<RequestedPackageLineItems>
<SequenceNumber>1</SequenceNumber>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>LB</Units>
<Value>5</Value>
</Weight>
<Dimensions>
<Length>7</Length>
<Width>7</Width>
<Height>7</Height>
<Units>IN</Units>
</Dimensions>
<CustomerReferences>
<CustomerReferenceType>INVOICE_NUMBER</CustomerReferenceType>
<Value>E2315141</Value>
</CustomerReferences>
<CustomerReferences>
<CustomerReferenceType>CUSTOMER_REFERENCE</CustomerReferenceType>
<Value>E2315141</Value>
</CustomerReferences>
</RequestedPackageLineItems>
</RequestedShipment>
</ProcessShipmentRequest>
【问题讨论】:
-
欢迎来到 Stack Overflow。你的问题不清楚。你展示的只是一堆数据,但没有代码。我们不知道您要做什么,该 API 是如何工作的,或者您是如何尝试做的。如果您认为问题与代码相关,请edit 您的问题并提供更多信息,例如您正在运行的代码。然而,我认为不是。错误信息非常清楚。您应该查看 FedEx 开发人员文档,找到错误 8522 并在那里阅读更多相关信息。您的货件似乎太大了。但这恐怕不是 Perl 的问题。
-
您的请求显示为
<PackageCount>3</PackageCount>,但您只列出了一个包。我认为这是你的问题。包裹数量需要与您提供的包裹数量相匹配。