When I am calling selling partner Amazon fba inbound shipment getShipments() api i am getting a NextToken.
But when again calling the API with NextToken it gives me below error even though NextToken exist -
[400]
{ "errors": [ { "code": "InvalidInput", "message": "Request is invalid - NextToken must not be empty", "details": "" } ] }
Below is my code:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// See README for more information on the Configuration object's options
$config = new SellingPartnerApi\Configuration([
"lwaClientId" => "<LWA client ID>",
"lwaClientSecret" => "<LWA client secret>",
"lwaRefreshToken" => "<LWA refresh token>",
"awsAccessKeyId" => "<AWS access key ID>",
"awsSecretAccessKey" => "<AWS secret access key>",
"endpoint" => SellingPartnerApi\Endpoint::NA // or another endpoint from lib/Endpoints.php
]);
$api = new SellingPartnerApi\Api\FbaInboundV0Api($config);
// Input data
$mpId = $_POST['txtMarketplaceId']; // Blocked since not required
$shpStatus = $_POST['txtShpStatus'];
try {
$shipments = $api->getShipments('SHIPMENT', [$mpId], [$shpStatus]);
if(!empty($shipments['payload']['shipment_data'])) {
// Check if it has next token
if(isset($shipments['payload']['next_token'])){
// Get next token
$nextToken = $shipments['payload']['next_token'];
// HERE I AM GETTING ERROR
$resNextToken = $api->getShipments('NEXT_TOKEN', ['NextToken' => $resNextToken]);
print_r($resNextToken); die;
}
} else {
echo "No shipments found";
}
} catch (Exception $e) {
echo "Exception when calling get shipments API '.$e->getMessage()";
}
?>
Am I making getShipments() request with NextToken incorrectly?