jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
408 stars 198 forks source link

Fulfillment Inbound API v2024-03-20 - createInboundPlan error #788

Closed k2priya closed 1 month ago

k2priya commented 1 month ago

while running createInboundPlan API, we are facing an error.

Error:
Bad Request (400) Response: { "errors": [ { "code": "BadRequest", "message": "WARNING: Address was unable to be verified. Please ensure that this is the address you wish to use before proceeding."

Code


use SellingPartnerApi\SellingPartnerApi;
use SellingPartnerApi\Enums\Endpoint;
use Saloon\Http\Response;
use Saloon\Http\PendingRequest;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use SellingPartnerApi\Seller\FBAInboundV20240320\Dto;      

require_once(__DIR__ . '/vendor/autoload.php');

$connector = SellingPartnerApi::seller(
    clientId: "XXXXXXXXXXXXXX-XXXXXXXXXXXXX",
    clientSecret: "XXXXXXXXXXXXXX-XXXXXXXXXXXXX",
    refreshToken: "XXXXXXXXXXXXXX-XXXXXXXXXXXXX",
    endpoint:  Endpoint::EU
);

    $inboundApi = $connector->FBAInboundV20240320();
try {
     $shipFromAddress = new Dto\AddressInput(
        'XXXXXXXXXXXXX,    // addressLine1
        'XXXXXXXXXXXXX',                // city
        'XX',                       // countryCode (Belgium)
        'XXXXXXXXXXXXX',         // name
        '+xx xxxx-xxxxxx',               // phoneNumber
        'xxxx'                 // postalCode

    );
    // Define the items
    $items = [];
    // Create first item
    $item1 = new Dto\ItemInput('SELLER','xxxxx', 'SELLER', 2); 
    $items[] = $item1;
    // Create second item
    $item2 = new Dto\ItemInput('SELLER','xxxxx','SELLER', 5); 
    $items[] = $item2;
    // Set the items in the request
     $requestParams = new Dto\CreateInboundPlanRequest(
        ['XXXXXXXXXXXXX'],          // destinationMarketplaces
        $items,                      // items (now correctly passed as an array)
        $shipFromAddress,            // sourceAddress
        'Inbound Plan v2 test'       // name (optional)
    );
    echo "<pre>";
    print_r($requestParams);
   // die;
    $response = $inboundApi->createInboundPlan($requestParams);
    echo "<pre>";
    // Print the response body
    print_r($response->body());
    echo "</pre>";
} catch (Exception $e) {
    // Handle exceptions
    echo 'Error: ' . htmlspecialchars($e->getMessage());
}
jlevers commented 1 month ago

Another client of mine is running into this too, for every single address they pass. No idea why. Luckily, it seems that the inbound shipment plan still gets created, it just takes a little longer to be available. You can use the getInboundOperationStatus endpoint to check for when the operation has finished.

I'm 99% sure this isn't related to this library, so I'm going to close the issue, but feel free to continue to discuss.