amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
612 stars 739 forks source link

[BUG] [SP-API] [Issue] - Exception when calling ReportsV20210630Api->getReports: [403] { "errors": [ { "message": "Access to requested resource is denied.", "code": "Unauthorized", "details": "" } ] } #2580

Closed aws-beginner-1108 closed 9 months ago

aws-beginner-1108 commented 1 year ago
I tested the below code in Post man and working fine with the credentials I provided in the configuration

I requested added all the information you explained in your example to fetch order or report but none of them is working

require 'vendor\autoload.php';
use SellingPartnerApi\Api\OrdersV0Api;
$config = new SellingPartnerApi\Configuration([
    "lwaClientId" => "--added lwa client id---",
    "lwaClientSecret" => "--added lwa client secret---",
    "lwaRefreshToken" => "--added lwa refresh token---",
    "awsAccessKeyId" => "--added AWS Access ID---",
    "awsSecretAccessKey" => "--added AWS Secret Access Key---",
    "endpoint" => SellingPartnerApi\Endpoint::NA  // or another endpoint from lib/Endpoints.php
]);

$apiInstance = new SellingPartnerApi\Api\ReportsV20210630Api($config);
$report_types = array('GET_MERCHANT_LISTINGS_ALL_DATA'); // string[] | A list of report types used to filter reports. Refer to [Report Type Values](https://developer-docs.amazon.com/sp-api/docs/report-type-values) for more information. When reportTypes is provided, the other filter parameters (processingStatuses, marketplaceIds, createdSince, createdUntil) and pageSize may also be provided. Either reportTypes or nextToken is required.
$processing_statuses = array("REPORT_PROCESSING_FINISHED");
$marketplace_ids = array('A2RV2UH9I0FQ8N'); 
$page_size = 10;
$created_since = '2023-04-01T00:00:00Z';
try {
    $result = $apiInstance->getReports($report_types, $processing_statuses, $marketplace_ids, $page_size, $created_since);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ReportsV20210630Api->getReports: ', $e->getMessage(), PHP_EOL;
}

Expected Result :- should be return of reports list

But 
Actual Result :-  Exception when calling ReportsV20210630Api->getReports: [403] { "errors": [ { "message": "Access to requested resource is denied.", "code": "Unauthorized", "details": "" } ] }
GJ-JG commented 1 year ago

Hi @aws-beginner-1108 , thanks for using SP-API.

Have you checked our blog about Unauthorized trouble shooting? Here are the related blogs you can refer to:

Best, Jiang

github-actions[bot] commented 9 months ago

This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please feel free to open a new issue and make a reference to this one.

github-actions[bot] commented 9 months ago

closed for inactivity