I'm getting an error in Amazon SP-API Orders API "Application do not have access to some or all requested resource"

Viewed 199

I'm getting an error "Application do not have access to some or all requested resource" when calling the method getOrders()/getOrder() from the Orders API.

I taken the code entirely from https://github.com/jlevers/selling-partner-api. I installed the composer require jlevers/selling-partner-api and followed the instruction to connect to the Selling Partner API.

In addition, I also tried calling $result = $apiInstance>getMarketplaceParticipations() which works without any particular error, so I don't think it's an error in the configurations.

Can anybody point me in the right direction to resolve this?

Code

<?php
require_once(__DIR__ . '/vendor/autoload.php');
    
$token = "<TOKEN>";
    
    use SellingPartnerApi\Api\SellersV1Api as SellersApi;
    use SellingPartnerApi\Configuration;
    use SellingPartnerApi\Endpoint;
    
    $config = new Configuration([
        "lwaClientId" => "amzn1.applica..",
        "lwaClientSecret" => "<clientSecret>",
        "lwaRefreshToken" => $token,
        "awsAccessKeyId" => "<accessKey>",
        "awsSecretAccessKey" => "<secretAcessKey>",
        "endpoint" => Endpoint::FE
    ]);
    
    $apiInstance = new SellingPartnerApi\Api\OrdersV0Api($config);
    $marketplace_ids = array('A1############'); 
    $created_after = '2022-07-27';
    
    try {
        $result = $apiInstance->getOrders($marketplace_ids);

        print "<pre>";
        print_r($result);
        print "</pre>";
    
    } catch (Exception $e) {
    
        echo 'Exception when calling OrdersV0Api->getOrders: ', $e->getMessage(), PHP_EOL;
    }

Error Message

Exception when calling OrdersV0Api->getOrders: [400] { "errors": [ { "code": "InvalidInput", "message": "Application do not have access to some or all requested resource", "details": "" } ] }
1 Answers

Put created after in this format:

$created_after = new \DateTime("2021-10-01");
$after_str = $created_after->format('Y-m-d\TH:i:s\Z');
Related