如何正确地将多箱货件的第一箱重量发送至 FedEx Api?

问题描述 投票:0回答:1

我正在尝试使用他们的 PHP API 运送 FedEx。我目前正在努力使多箱运输正常工作,并且遇到了以下问题。当我运送第一个盒子时,我收到一条错误消息,提示需要重量,即使我已经提供了 TotalWeight 和 RequestedPackageLineItems 重量。

以下是我发送到 API 的请求示例(所有敏感数据均替换为示例数据):

Array
(
    [WebAuthenticationDetail] => Array
        (
            [UserCredential] => Array
                (
                    [Key] => saqrZmAe6vWLmgsw
                    [Password] => CECXPgfyftNU7cEdlvwOGrWfR
                )

        )

    [Version] => Array
        (
            [Major] => 7
            [Intermediate] => 0
            [Minor] => 0
        )

    [ClientDetail] => Array
        (
            [AccountNumber] => 798914457
            [MeterNumber] => 209966743
        )

    [RequestedShipment] => Array
        (
            [Shipper] => Array
                (
                    [Contact] => Array
                        (
                            [CompanyName] => Example Inc 
                            [PhoneNumber] => 800-555-0150
                        )

                    [Address] => Array
                        (
                            [StreetLines] => Array
                                (
                                    [0] => 231 Example Rd               
                                )

                            [City] => Example                        
                            [StateOrProvinceCode] => IL
                            [PostalCode] => 60601-1005
                            [CountryCode] => US
                        )

                )

            [Recipient] => Array
                (
                    [Contact] => Array
                        (
                            [PersonName] => Jimmy Example
                            [CompanyName] => Example LLC
                            [PhoneNumber] => 241-555-0110
                        )

                    [Address] => Array
                        (
                            [StreetLines] => Array
                                (
                                    [0] => 10 Example Ave
                                    [1] => 
                                )

                            [City] => Example
                            [StateOrProvinceCode] => FL
                            [PostalCode] => 33101-1041
                            [CountryCode] => US
                        )

                )

            [RateRequestTypes] => LIST
            [PackageCount] => 3
            [PackageDetail] => INDIVIDUAL_PACKAGES
            [RequestedPackageLineItems] => Array
                (
                    [0] => Array
                        (
                            [Weight] => Array
                                (
                                    [Value] => 18
                                    [Units] => LB
                                )

                            [CustomerReferences] => Array
                                (
                                    [0] => Array
                                        (
                                            [CustomerReferenceType] => CUSTOMER_REFERENCE
                                            [Value] => Shipper # 99
                                        )

                                )

                        )

                    [SequenceNumber] => 1
                )

            [ShippingChargesPayment] => Array
                (
                    [PaymentType] => RECIPIENT
                    [Payor] => Array
                        (
                            [CountryCode] => US
                            [AccountNumber] => 947636980
                        )

                )

            [LabelSpecification] => Array
                (
                    [LabelStockType] => STOCK_4X6.75_LEADING_DOC_TAB
                    [LabelStockTypeSpecified ] => 1
                    [LabelFormatType] => COMMON2D
                    [ImageType] => EPL2
                    [LabelPrintingOrientation] => TOP_EDGE_OF_TEXT_FIRST
                )

            [ShipTimestamp] => 2023-08-17T16:14:15-04:00
            [DropoffType] => REGULAR_PICKUP
            [PackagingType] => YOUR_PACKAGING
            [TotalWeight] => Array
                (
                    [Units] => LB
                    [Value] => 54
                )

        )

    [ReturnTransitAndCommit] => 1
)

这是我收到的错误:

(
    [Severity] => ERROR
    [Source] => ship
    [Code] => 2458
    [Message] => weight is required
    [LocalizedMessage] => weight is required
    [MessageParameters] => stdClass Object
        (
            [Id] => PACKAGE_INDEX
            [Value] => 1
        )

)

我是否缺少一些必需的重量字段?

php fedex
1个回答
0
投票

事实证明,所给出的错误是具有欺骗性的。任何权重字段都没有问题。我犯了一个错误,“SequenceNumber”字段没有正确嵌套在 RequestedPackageLineItems 中。

一旦 SequenceNumber 从直接嵌套在 RequestedPackageLineItems 内移动到该数组的第一个元素内,请求就会通过。

© www.soinside.com 2019 - 2024. All rights reserved.