phpfedex

How do I correctly send the weight of the first box of a multibox shipment to FedEx Api?


I am trying to ship FedEx using their PHP API. I'm currently working on getting multi-box shipping to work, and I've run into the following issue. When I ship the first box, I'm getting an error that a weight is required, even though I've provided both a TotalWeight and a RequestedPackageLineItems Weight.

Here is an example of the request that I'm sending to the API (with all sensitive data replaced with example data):

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
)

Here is the error that I'm receiving:

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

)

Is there some required weight field that I'm missing?


Solution

  • It turned out that the error being given was deceptive. There wasn't a problem with any of the weight fields. I made a mistake, and the "SequenceNumber" field was not properly nested inside of the RequestedPackageLineItems.

    Once the SequenceNumber was moved from being nested directly inside RequestedPackageLineItems to being inside the first element of that array, the request goes through.