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
580 stars 730 forks source link

Report status return FATAL #398

Closed gaurav-webs closed 3 months ago

gaurav-webs commented 3 years ago

When I call a report in a loop and when we get the report data it always returns a FATAL status, what is the reason?

I am fetching reports of the whole week in a loop day by day, so I get the report id from createReport API, but when I call getReport it will always return FATAL, can anyone explain to me why it returns FATAL.

ezpinsky commented 3 years ago

Hey, You should try to provide a bit more information for an issue so that the community can better help you. What SDK are you using? What Report Type were you requesting? What marketplace(s)? What date range? Anyhow, from my experience, getting a FATAL status can be the result of multiple things. Unfortunately the API rarely tells you why its FATAL so its kind of up to you to figure it out. Interestingly enough, the documentation indicates they MIGHT tell you the reason for FATAL status in the reportDocumentId property but I have yet to see a reason for FATAL status there.

Potential Reasons

  1. There is no data available for the date range specified.

  2. The date range you specified does not follow the date range specifications in the docs.

  • Some report types have limitations on how large or small the date range can be. Carefully check the description of the report type you are requesting here for those details.
  1. The client does not sell in the marketplace(s) that you specified in the request

  2. You've made the same exact request too many times in a row. This is a weird issue I found when I make the same exact request for a report multiple times it results in FATAL.

Potential Solutions

  1. Try experimenting with different date ranges than what you have been doing.

  2. Confirm manually via seller central that there is data for the date ranges you are specifying.

Hope this helps. Good Luck!

gaurav-webs commented 3 years ago

Hey @ezpinsky, Thanks for the reply,

I have a logic for reports to check the whole week data in a loop day by day, and if it is found that any of the day's reports are not generated then it will call that particular date report data,

like let's say, my cron is running daily and it will execute the loop something like this

$firstday = date('Y-m-d', strtotime("this week")); 
$end_date = date('Y-m-d');

while (strtotime($firstday) <= strtotime($end_date)) {
    if($firstday <= $end_date){
        //my logic to check the report is generated for that day if not then call create report
        $startDate = date('Y-m-d', strtotime('-1 day', strtotime($firstday)));
        $startDate .= " 00:02:00";
        $endDate = $firstday;
        $endDate .= " 00:01:59";
        $reportType = 'GET_FBA_FULFILLMENT_INVENTORY_HEALTH_DATA';
    }
    $firstday = date ("Y-m-d", strtotime("+1 day", strtotime($firstday)));
}

So this is my logic that how I can fetch the report for a single day.

Also, this same logic I was using in MWS and is working fine till now. I am facing this issue only in SP API.

Feng-Xg commented 3 years ago

STEP I have the same problem.

Javadebi commented 2 years ago

I have the same problem, I think there is a rate limiter on it

ynaft commented 2 years ago

I have the same problem

qrcf commented 2 years ago

Same issue here.

ynaft commented 2 years ago

If this might be helpful, while investigating the reason to the FATAL response, I found that the reports which show FATAL - in my case at least - in the sp-api, show CANCELED when pulling the report request list from MWS, which basically means that because of allowance limits for this type of report it got CANCELED/FATAL

orpeleg8 commented 2 years ago

Same issue, specifically for report type 'GET_FBA_FULFILLMENT_CURRENT_INVENTORY_DATA'.

samborambo305 commented 2 years ago

Same issue

NA-Dev commented 2 years ago

Same issue for me. You have to follow long trails of links in documentation to actually see what is and isn't required in API calls for different reports.

To figure out what is causing the FATAL status: get a documentID from the FATAL status report, make a call to get the report download link, save the response of that link as *.gzip, and extract. The resulting document should state what went wrong in generating the report.

kherkeladze commented 1 year ago

When you open documentID link, you may see SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data error, but if you save page with .gzip extension and decompress it, you will get text file with detailed error message

rejeenald commented 1 year ago

I have the issue.

wcasalinuevo commented 1 year ago

I also been struggling with this. Below is what I noticed: Putting empty dates to some reports returns Fatal even though documentation says dates are not required. After putting in dates, attempting to request same report more than once, generates Fatal error. After changing the dates a bit, I was successful in generating a report.

I have been unsuccessful in generating the GET_FBA_FULFILLMENT_INVENTORY_HEALTH_DATA report no matter what I try in both the SPA and MWS. After to unresolved tickets with the developers team at Amazon, I have to look into another solution. One ticket the developers said the issue was fixed and the second ticket he told me about parameters and quoted me the documentation.

humzamanzoor commented 1 year ago

Has anyone found the solution to this problem? By trying different number of days works but it doesn't when getting the report o the same number of days repetitively.

ashish-atidiv commented 1 year ago

Has anyone found the solution to this problem? By trying different number of days works but it doesn't when getting the report o the same number of days repetitively.

Me too. I am also getting the same issue. My reports are accepted and complete if I run them through a simple script. But when I request them from my module, it return s FATAL.

humzamanzoor commented 1 year ago

Has anyone found the solution to this problem? By trying different number of days works but it doesn't when getting the report o the same number of days repetitively.

Me too. I am also getting the same issue. My reports are accepted and complete if I run them through a simple script. But when I request them from my module, it return s FATAL.

Hey I worked on it few days ago and I found out it works per day. You cannot retrieve the report for the same number of days, it will work once only for the same number of days.

ashish-atidiv commented 1 year ago

Hey @humzamanzoor Thanks for the comment. Did you mean that on a given day, we cannot fetch the same report for same dataStartTime and dataEndTime multiple times?

What if the reportOptions are different but start and end time are same?

humzamanzoor commented 1 year ago

Hey @humzamanzoor Thanks for the comment. Did you mean that on a given day, we cannot fetch the same report for same dataStartTime and dataEndTime multiple times?

What if the reportOptions are different but start and end time are same?

Yes, you are right. I searched about it and I didn't find anything about it. So, this is my own analysis because I checked all the parameters on different days.

I don't exactly remember about report options.

JalawanAman commented 12 months ago

Hello everyone,

I'm Jalawan and I've run into an issue while using the Amazon Selling Partner API. I'm looping through the create_document method, setting the start_date to '2023-01-01T00:00:23Z' and the end_date to '2023-01-31T23:59:59Z'. I'm using the US marketplace ID and the report type GET_FBA_MYI_ALL_INVENTORY_DATA.

I have incorporated some sleep times in my code to account for the rate limits of the API. Here's the relevant portion:

"def get_api_data(report_type, credentials_file_path, sellingPartnerId, marketplace_name, marketplace_id, start_date, end_date, brand, timezone, schema):

    try:
    # Load credentials from the provided file path
    credentials = load_credentials(credentials_file_path)

    # Initialize Reports API client
    reports_api = get_report_api(credentials=credentials)

    # Create order report
    time.sleep(100)
    response = reports_api.create_report(
        reportType=report_type,
        marketplaceIds=[marketplace_id],
        dataStartTime=start_date,
        dataEndTime=end_date
    )

    # print(response)

    report_id = response.payload["reportId"]

    # Check report status
    while True:
        report_status = reports_api.get_report(report_id)
        print(report_status)

        if report_status.payload["processingStatus"] == "DONE":
            break
        elif report_status.payload["processingStatus"] == "FATAL":
            return None
        else:
            time.sleep(35)

        if report_status.payload["processingStatus"] == "CANCELLED":
            print(f"{CRED}Report has been cancelled...{CEND}")
            exit()

    # Get report document
    report_document_id = report_status.payload["reportDocumentId"]

    time.sleep(65)
    report_data = reports_api.get_report_document(
        report_document_id, download=True)

    print(report_data)

    # Use the report data (e.g., parse CSV or JSON)
    orders_data = parse_report_data(
        report_data, sellingPartnerId, brand, start_date, end_date, timezone, schema)

    return orders_data

except SellingApiBadRequestException as e:

    logging.error("SellingApiBadRequestException occurred", exc_info=True)
    raise e

except Exception as e:
    logging.error("Unexpected exception occurred", exc_info=True)
    raise e

"

and here is how I am getting a response

{'errors': None, 'headers': {'Server': 'Server', 'Date': 'Fri, 29 Sep 2023 18:41:32 GMT', 'Content-Type': 'application/json', 'Content-Length': '266', 'Connection': 'keep-alive', 'x-amz-rid': 'K3ESJZACWSN9TCTJB6VR', 'x-amzn-RateLimit-Limit': '2.0', 'x-amzn-RequestId': 'ffef1273-15f3-4b31-b9e1-2343960643f5', 'x-amz-apigw-id': 'OPFffef127315f3', 'X-Amzn-Trace-Id': 'Root=1-65171a5c-ffef127315f34b31', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload'}, 'next_token': None, 'pagination': None, 'payload': {'createdTime': '2023-09-29T18:41:30+00:00', 'dataEndTime': '2023-01-31T23:59:59+00:00', 'dataStartTime': '2023-01-01T00:00:23+00:00', 'marketplaceIds': ['ATVPDKIKX0DER'], 'processingStatus': 'IN_QUEUE', 'reportId': '376791019629', 'reportType': 'GET_FBA_MYI_ALL_INVENTORY_DATA'}, 'rate_limit': '2.0'} {'errors': None, 'headers': {'Server': 'Server', 'Date': 'Fri, 29 Sep 2023 18:42:09 GMT', 'Content-Type': 'application/json', 'Content-Length': '361', 'Connection': 'keep-alive', 'x-amz-rid': '74KH7D6JTZMNTCTEA25H', 'x-amzn-RateLimit-Limit': '2.0', 'x-amzn-RequestId': 'cd170a54-6735-406d-aab9-dac9b84991e2', 'x-amz-apigw-id': 'OPFcd170a546735', 'X-Amzn-Trace-Id': 'Root=1-65171a81-cd170a546735406d', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload'}, 'next_token': None, 'pagination': None, 'payload': {'createdTime': '2023-09-29T18:41:30+00:00', 'dataEndTime': '2023-01-31T23:59:59+00:00', 'dataStartTime': '2023-01-01T00:00:23+00:00', 'marketplaceIds': ['ATVPDKIKX0DER'], 'processingEndTime': '2023-09-29T18:41:46+00:00', 'processingStartTime': '2023-09-29T18:41:37+00:00', 'processingStatus': 'FATAL', 'reportId': '376791019629', 'reportType': 'GET_FBA_MYI_ALL_INVENTORY_DATA'}, 'rate_limit': '2.0'}

=======================================

so if there is anyone who can understand my issue please I need help. Thank You

JalawanAman commented 12 months ago

Additionally, I'm finding it challenging to navigate the SP API documentation. While the Report API section explains that we need to provide the marketplace, start and end date, and report type, it also hints at additional parameters specific to each report type. However, when I checked the report types section, I couldn't find details on these extra parameters.

If anyone knows where in the documentation these details are elaborated upon, I'd really appreciate a pointer!

Feng-Xg commented 11 months ago

'processingStatus': 'FATAL', @JalawanAman The second response content containes ''processingStatus': 'FATAL'", may it means your request parameter is wrong. https://developer-docs.amazon.com/sp-api/docs/report-type-values-fba

Daniell-Green commented 11 months ago

I had the same problem with GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA. I checked the status every 5 seconds and got FATAL response for every other account. I changed it to check only once every 30 seconds, which has has reduced the amount of FATAL errors to (almost) 0, for me.

diamond-fish commented 11 months ago

Not to sound like a broken record, but just noticed our inventory reports have been empty recently and traced it to this error:

{
  "reportType": "GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA",
  "processingEndTime": "2023-10-24T20:51:05+00:00",
  "processingStatus": "FATAL",
  "marketplaceIds": [
    "..."
  ],
  "reportId": "...",
  "dataEndTime": "2023-10-24T20:49:44+00:00",
  "createdTime": "2023-10-24T20:49:44+00:00",
  "processingStartTime": "2023-10-24T20:50:57+00:00",
  "dataStartTime": "2023-10-24T20:49:44+00:00"
}

Did anything change recently?

Note that we poll every 10 seconds and it goes from IN_QUEUE -> IN_PROGRESS (sometimes) -> FATAL status every time (it wasn't always like this since we were obviously getting inventory data before).

grantrosse commented 8 months ago

Not to sound like a broken record, but just noticed our inventory reports have been empty recently and traced it to this error:

{
  "reportType": "GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA",
  "processingEndTime": "2023-10-24T20:51:05+00:00",
  "processingStatus": "FATAL",
  "marketplaceIds": [
    "..."
  ],
  "reportId": "...",
  "dataEndTime": "2023-10-24T20:49:44+00:00",
  "createdTime": "2023-10-24T20:49:44+00:00",
  "processingStartTime": "2023-10-24T20:50:57+00:00",
  "dataStartTime": "2023-10-24T20:49:44+00:00"
}

Did anything change recently?

Note that we poll every 10 seconds and it goes from IN_QUEUE -> IN_PROGRESS (sometimes) -> FATAL status every time (it wasn't always like this since we were obviously getting inventory data before).

I am also having issues with the GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA and GET_FBA_MYI_ALL_INVENTORY_DATA reports. There seems to be some undocumented restriction going on I can't seem to put my finger on? My gut says that the api ignores the start/end times and you can only request every 30 minutes.

shreeharsh-a commented 3 months ago

Please reach out to developer support so that we can better help you with issues related to SP API.

Note: SP API related issues / troubleshooting support is managed by a different team. We can help if the issue is related to the content published on this repo.