Closed sydy closed 7 months ago
Could you please provide your full code? Without more context, it's hard for me to figure out where the issue might be. I think this is relatively unlikely to be an issue with this SDK, but it's certainly possible.
Hello, thank you for your response. Please provide the following details: Framework: Laravel 10.10 Report Type: GET_MERCHANT_LISTINGS_ALL_DATA
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use SellingPartnerApi\SellingPartnerApi;
use SellingPartnerApi\Enums\Endpoint;
class Amazon extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:amazon';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
$connector = SellingPartnerApi::make(
clientId: config('services.amazon.client_id'),
clientSecret: config('services.amazon.client_secret'),
refreshToken: config('services.amazon.refresh_token'),
endpoint: Endpoint::NA,
)->seller();
$response = $connector->reports()->getReport(64570019820);
$data = $response->json();
print_r($data);
$response = $connector->reports()->getReportDocument(
$data['reportDocumentId'],
$data['reportType']
);
print_r($response->json());
}
}
Saloon\Exceptions\Request\ClientException
Bad Request (400) Response: {
"errors": [
{
"code": "InvalidInput",
"message": "Invalid or unsupported document ID found",
"details": ""
}
]
}
at vendor/saloonphp/saloon/src/Helpers/RequestExceptionHelper.php:51
47▕ $response->clientError() => ClientException::class,
48▕ default => RequestException::class,
49▕ };
50▕
➜ 51▕ return new $requestException($response, null, 0, $previous);
52▕ }
53▕ }
54▕
+36 vendor frames
37 app/Console/Commands/Amazon.php:45
SellingPartnerApi\Seller\ReportsV20210630\Api::getReportDocument()
+12 vendor frames
50 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
Same issue here trying to get report document for report type "GET_FLAT_FILE_OPEN_LISTINGS_DATA".
When creating GetReportDocument this adds RestrictedDataToken on every report, no matter type.
But according to amazon official docs only some reports are restricted:
@jbaelo thanks for the PR! Would you mind giving me push permissions to your PR branch (instructions here)? Because the GetReportDocument
class is autogenerated, we need to go about this a slightly different way.
(Whoops, meant to comment that on the PR itself, not this issue)
Excuse me if I intrude, but why does $connector->reports()->getReportDocument() request and require a second parameter? Amazon documentation is very clear, the APIs only accept a single parameter, the reportDocumentId https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#getreportdocument
It's to enable the document helper functionality that I've built into this library (see the DownloadsDocument
and UploadsDocument
traits). You're right that it's a departure from the Amazon spec, but I think it's worth it since it enables quite a lot of extra functionality and is very little additional work for end users.
I'm getting the same issue with GET_MERCHANT_LISTINGS_DATA. I'm pretty sure I passed all data correctly. I can see in a reports.json file, this report type isn't restricted.
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://sellingpartnerapi-na.amazon.com/tokens/2021-03-01/restrictedDataToken
resulted in a400 Bad Request
response: { "errors": [ { "code": "InvalidInput", "message": "Invalid or unsupported document ID found", " (truncated...)
Edit: Ok I see the open PR will address the issue. I'll wait for it to get merged.
@j-masci this is because of an issue with how the library is generating RDTs – once I'm able to push to the fork branch on PR #682 (cc @jbaelo), I'll release the fix. If that doesn't happen in the next day or so I'll just commit it all directly, but I like to go through people's PRs whenever possible so that they get credit as a contributor.
@jlevers "Allow edits and access to secrets by maintainers" option not showing in PR, anyway we give you write permission to our repo
This should be fixed in v6.0.5
.
Problem description:
When calling the getReportDocument() method, correct $documentId and $reportType parameters were used, but an incorrect response was received.
Error:
Code