2012-12-26 140 views
4

我使用FeDex API來發貨標籤打印。標籤1個打印全成,但是當我試圖打印多包我得到一個錯誤:Fedex API。運輸標籤。多包裹發貨

stdClass Object 
(
[Severity] => ERROR 
[Source] => ship 
[Code] => 2463 
[Message] => The number of RequestedPackages in the RequestedShipment must be equal to 1 
[LocalizedMessage] => The number of RequestedPackages in the RequestedShipment must be equal to 1 
) 

在要求我包括總權重,PackageCount,但它是helpn't

$request['WebAuthenticationDetail'] = array('UserCredential' =>array('Key' => $auth['key'], 'Password' => $auth['password'])); 
$request['ClientDetail'] = array('AccountNumber' => $auth['accountNumber'], 'MeterNumber' => $auth['meterNumber']); 
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Ground Domestic Shipping Request v12 using PHP ***'); 
$request['Version'] = array('ServiceId' => 'ship', 'Major' => '12', 'Intermediate' => '1', 'Minor' => '0'); 
$request['RequestedShipment'] = array('ShipTimestamp' => date('c'), 
             'DropoffType' => 'REGULAR_PICKUP', // valid values REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION 
             'ServiceType' => 'FEDEX_GROUND', // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ... 
             'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... 
             'Shipper' => $this->addShipper(), 
             'Recipient' => $this->recipient, 
             'ShippingChargesPayment' => $this->addShippingChargesPayment(), 
             'LabelSpecification' => $this->addLabelSpecification(), 
             'RateRequestTypes' => array('LIST'), // valid values ACCOUNT and LIST 
             'PackageCount' => count($this->packages), 
             'TotalWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'), 
             'TotalShipmentWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'), 
             'PackageDetail' => 'INDIVIDUAL_PACKAGES',           
             'RequestedPackageLineItems' => $this->packageLineItem//array('0' => $this->packageLineItem) 
);  


$this->packageLineItem[] = array('SequenceNumber'=>$i, 
       'GroupPackageCount' => count($this->packages), 
       'MasterTrackingID' => '123123123123', 
       'TotalShipmentWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'), 
       'Weight' => array('Value' => $this->packages[$i-1], //weight!!!!!!!!!!!!! 
           'Units' => 'LB'), 
       'CustomerReferences' => array('0' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 
                 'Value' => 'GR4567892'), // valid values CUSTOMER_REFERENCE, INVOICE_NUMBER, P_O_NUMBER and SHIPMENT_INTEGRITY 
              '1' => array('CustomerReferenceType' => 'INVOICE_NUMBER', 
                 'Value' => 'INV4567892'), 
              '2' => array('CustomerReferenceType' => 'P_O_NUMBER', 
                 'Value' => 'PO4567892')), 
       'SpecialServicesRequested' => array('SpecialServiceTypes' => array('COD'), 
                'CodDetail' => array('CodCollectionAmount' => array('Currency' => 'USD', 'Amount' => 150), 
                     'CollectionType' => 'ANY')// ANY, GUARANTEED_FUNDS 
               ) 
); 

有誰知道如何成爲一個有效的請求?

+0

你有沒有得到這個答案?儘管「MasterTrackingId」正確,但我仍然收到同樣的錯誤。 – user766987

回答

0

FeDex手冊有錯誤:「MasterTrackingID」錯誤。 「MasterTrackingId」是正確的。

9

聯邦快遞費率API聯邦快遞航運API之間的差異。您可以使用一個SOAP請求對多個包進行評級;但是,若要發送多件貨件(MPS),則必須爲每個包裹執行送貨請求。

第一封裝(封裝在第一請求中),將是您萬事達包含主跟蹤號碼。一旦你有這個主跟蹤號碼,你必須把它附加到其餘包裹的送貨請求。請參閱最新聯邦快遞開發人員指南瞭解有關MPS貨件的更多信息,並下載從FedEx開發人員門戶網站執行快遞國內MPS貨件的示例。

需要注意的是,運送過程不會作爲交易發生,因此如果您嘗試運送3個包裹,且包裹1和2已成功提交,但包裹3由於未知原因而失敗,則您負責取消包裹1和2或重新提交包裹3.我會建議任何人在創建實際貨件之前驗證貨件(使用相同的運輸API)。

最好!

+0

https://www.fedex.com/us/developer/WebHelp/fsms/1401/dvg/DVG-WebHelp/2_7_4_1_Single_Shot_Shipping_Method.htm中的頁面解釋了多件貨物的單件運輸方式,但我一直得到同樣的錯誤。任何想法爲什麼? – trss

+0

我的意思是,你的答案表明這是不可能的。難道這不再被支持? – trss