对象序列化程序:从 jlevers/selling-partner-api 使用 confirmShipment() 时出错 .php

ObjectSerializer.php Error when using confirmShipment() from jlevers/selling-partner-api

提问人:R Gomez 提问时间:11/10/2023 更新时间:11/10/2023 访问量:8

问:

我正在尝试使用来自 jlevers/selling-partner-api 的 confirmShipment() 确认亚马逊的订单,如下面的 GitHub 所述,但我收到致命错误:未捕获的错误:找不到类“null”/vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php:366

https://github.com/jlevers/selling-partner-api/

我成功创建了$apiInstance和$payload,但是当我执行它时,我从 ObjectSerializer 收到以下错误:

Fatal error: Uncaught Error: Class 'null' not found in /vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php:366 Stack trace: #0 /vendor/jlevers/selling-partner-api/lib/Api/OrdersV0Api.php(92):
 SellingPartnerApi\ObjectSerializer::deserialize(Object(stdClass), 'null', Array) #1 /vendor/jlevers/selling-partner-api/lib/Api/OrdersV0Api.php(55):
 SellingPartnerApi\Api\OrdersV0Api->confirmShipmentWithHttpInfo('114-0297756-279...', Object(SellingPartnerApi\Model\OrdersV0\ConfirmShipmentRequest)) #2 /amazon_settings.php(457):
 SellingPartnerApi\Api\OrdersV0Api->confirmShipment('114-0297756-279...', Object(SellingPartnerApi\Model\OrdersV0\ConfirmShipmentRequest)) #3 /scripts/test.php(65):
 Amazon->fn_confirmShipment('/home/scripts...') #4 {main} thrown in /vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php on line 366

这是我正在使用的:

$apiInstance = new SellingPartnerApi\Api\OrdersV0Api($config);
$order_id = 'order_id_example'; // string | An Amazon-defined order identifier, in 3-7-7 format (correct order number being passed).
$payload = new \SellingPartnerApi\Model\OrdersV0\ConfirmShipmentRequest(); // \SellingPartnerApi\Model\OrdersV0\ConfirmShipmentRequest | Request body of confirmShipment.

try {
    $apiInstance->confirmShipment($order_id, $payload);
} catch (Exception $e) {
    echo 'Exception when calling OrdersV0Api->confirmShipment: ', $e->getMessage(), PHP_EOL;
}

这是 ConfirmShipmentRequest 生成的$payload:

SellingPartnerApi\Model\OrdersV0\ConfirmShipmentRequest Object
(
    [container:protected] => Array
        (
            [package_detail] => Array
                (
                    [package_reference_id] => 2790602
                    [carrier_code] => FedEx
                    [shipping_method] => Ground
                    [tracking_number] => 63828440XXX
                    [ship_date] => 2023-11-07T07:17:07-00:00
                    [order_items] => Array
                        (
                            [order_item_id] => 87699213804801
                            [quantity] => 4
                        )

                )

            [cod_collection_method] => 
            [marketplace_id] => ATVPDKIKX0DER
        )

)

我是否错误地传递了有效负载中的信息?错误说找不到类“null”,但我在 $apiInstance->confirmShipment 中传递了所有参数,任何帮助都值得赞赏

我尝试省略order_items,也将它们作为嵌套数组传递

致命错误 amazon-selling-partner-api

评论


答: 暂无答案