Skip to content

GetOrders SP-API Sandbox : Error 400 again ? #888

Description

@guldil

Problem description:

It is my first development with SP-API and i can't get a "test connecton" working.
I created a developper account in solutionproviderportal and a SandBox application.
I have client id, client secret and i create a refresh token from solutionproviderportal too.
I'm waiting for access to a true Seller Account from my client.
I'm in France so i test with EU_SANDBOX and A13V1IB3VIYZZH from MarketPlace ID.
I read all the issues about error 400, none of these correspond to my problem

Error:

Get orders Failed.

In RequestException.php line 111:
                                                                                                                                                                                     
  Client error: `GET https://sandbox.sellingpartnerapi-eu.amazon.com/orders/v0/orders?MarketplaceIds=A13V1IB3VIYZZH&CreatedAfter=2025-09-01T00%3A00%3A00Z` resulted in a `400 Bad    
  Request` response:                                                                                                                                                                 
  {                                                                                                                                                                                  
    "errors": [                                                                                                                                                                      
      {                                                                                                                                                                              
        "code": "InvalidInput",                                                                                                                                                      
        "message": "Could not match input arguments",                                                                                                                                
        "details": (truncated...)

Code

<?php

namespace App\Command;

use SellingPartnerApi\SellingPartnerApi;
use SellingPartnerApi\Enums\Endpoint;
use Psr\Http\Message\RequestInterface;
use Saloon\Http\PendingRequest;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
    name: 'amazon:test-connection',
    description: 'Teste la connexion à l\'API Amazon SP-API (Orders)',
)]
class AmazonTestConnectionCommand extends Command
{
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        //try {
            $connector = SellingPartnerApi::seller(
                clientId: $_ENV['AMAZON_CLIENT_ID'],
                clientSecret: $_ENV['AMAZON_CLIENT_SECRET'],
                refreshToken: $_ENV['AMAZON_REFRESH_TOKEN'],
                endpoint: Endpoint::EU_SANDBOX,  // Or Endpoint::EU, Endpoint::FE, Endpoint::NA_SANDBOX, etc.
            );

            //debug request
            $connector->debugRequest(
                function (PendingRequest $pendingRequest, RequestInterface $psrRequest) {
                    var_dump($pendingRequest->headers()->all(), $psrRequest);
                }
            );

            $ordersApi = $connector->ordersV0();
            $response = $ordersApi->getOrders(
                ['A13V1IB3VIYZZH'],
                '2025-09-01T00:00:00Z'
            );

            $output->writeln('<info>Connexion réussie !</info>');
            $output->writeln(json_encode($response, JSON_PRETTY_PRINT));

            return Command::SUCCESS;
        // } catch (\Throwable $e) {
        //     $output->writeln('<error>Erreur : ' . $e->getMessage() . '</error>');
        //     return Command::FAILURE;
        // }
    }
}

Seller Central SP API config page screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions