jlevers / selling-partner-api

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

ReportsAPI -> createReport 500 Internal Error Always #17

Closed cpiggott closed 3 years ago

cpiggott commented 3 years ago

Hello,

Love this library!

I am working on switching from MWS over to the SP-API and this tool is great. I was wondering if you have had any luck with the ReportsAPI working?

Whenever I try to create a report, I get back a 500 "Internal Failure" message from the API. Code and Response are below.

Code

    $api_tr = new ReportsApi();
        $api_tr->createReport(new CreateReportSpecification([
            'report_type' => ['GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE'],
            'date_start_time' => Carbon::now()->subDay()->startOfDay()->toISOString(),
            'date_end_time' => Carbon::now()->subDay()->endOfDay()->toISOString(),
            'marketplace_ids' => ['ATVPDKIKX0DER']
        ]));

Response

"errors": [
    {
      "code": "InternalFailure",
      "message": "We encountered an internal error. Please try again.",
      "details": ""
    }
cpiggott commented 3 years ago

Doing the following worked for me:

        $report_type = new CreateReportSpecification();
        $report_type->setDataStartTime(Carbon::now()->subDay()->startOfDay()->toDateTime());
        $report_type->setDataEndTime(Carbon::now()->subDay()->endOfDay()->toDateTime());
        $report_type->setReportType('GET_FLAT_FILE_OPEN_LISTINGS_DATA');
        $report_type->setMarketplaceIds(['ATVPDKIKX0DER']);
        $api_tr->createReport($report_type);