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: `GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL` report returns ALL data and ignores `marketplaceIds` filter #1859

Closed moltar closed 1 year ago

moltar commented 3 years ago

When requesting GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL report and specifying a marketplaceIds filter, this filter gets completely ignored and the data from all marketplaces is returned.

E.g. when I request data for A2NODRKZP88ZB9 (Sweden), I get data for Amazon UK.

        {
            "reportType": "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL",
            "processingEndTime": "2021-09-16T10:41:36+00:00",
            "processingStatus": "DONE",
            "marketplaceIds": [
                "A2NODRKZP88ZB9"
            ],
            "reportDocumentId": "amzn1.spdoc.1.3.f5126eb4-b7f7-492f-96d8-ae1ae270d6c0.T2QW7PSJ9YWOIR.2407",
            "reportId": "202862018886",
            "dataEndTime": "2021-09-16T10:25:12+00:00",
            "createdTime": "2021-09-16T10:41:13+00:00",
            "processingStartTime": "2021-09-16T10:41:19+00:00",
            "dataStartTime": "2021-09-16T03:15:36+00:00"
        }

If you download this report, it will contain data for Amazon.co.uk.

screenshot-20210916T193347-gd39TYOn


Relevant: amzn/selling-partner-api-models#1337, amzn/selling-partner-api-models#1847

jamesp26 commented 3 years ago

Its always been like this, even in the MWS days. Just have to learn to live with it :)

moltar commented 3 years ago

@jamesp26 Thank you for the confirmation of the bug 🐛

I understand that it has been historically broken. But either it needs to be fixed or this behaviour should be documented.

By the way, do you know how it works? Does it return all data for one merchant ID? Or does it group by region? Eg NA, EU? And how to reliably attribute data to a specific marketplace? By the sales channel column?

Thank you.

moltar commented 3 years ago

Hey @jlevers do you know anything about this? Cheers!

jlevers commented 3 years ago

I'm pretty sure it groups it by region. I just tested this, and it seems to be true -- when I use used the US marketplaceId, I got these sales channels: Amazon.com, Amazon.ca, and Non-Amazon. This is with a Seller account that only participates in the US and CA marketplaces.

moltar commented 3 years ago

Thanks, @jlevers.

It's hard to test this logic and assumptions for various reasons.

It is still not clear whether auth works across regions, as documented. In my experience and support telling me this, it does not work this way. And every region needs a separate auth. So I am wondering then is it maybe per auth, and not per region. Per region data grouping is just being a side effect of having per region auth.

jlevers commented 3 years ago

Per region data grouping is just being a side effect of having per region auth.

With the SP API, all regions are accessible with the same auth creds, so I'm not sure if that's true anymore.

moltar commented 3 years ago

With the SP API, all regions are accessible with the same auth creds, so I'm not sure if that's true anymore.

Hm, not with my experience.

Have you tried accessing EU marketplaces with the auth that went thru NA region?

Previously we were getting access denied. And MWS / SP API support had confirmed that we need to have a separate application and separate auth for each region.

johnkw commented 3 years ago

Where did you get the idea that the report was supposed to work that way? (See also bug amzn/selling-partner-api-models#378 that none of these reports are documented.)

moltar commented 3 years ago

Where did you get the idea that the report was supposed to work that way? (See also bug amzn/selling-partner-api-models#378 that none of these reports are documented.)

I got the idea from the docs. There's a marketplaceId parameter, which is documented globally for all reports. There's no documented exception for this report type.

johnkw commented 3 years ago

The only thing I see in https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reports_2021-06-30.md#createreport is "The report document's contents will contain data for all of the specified marketplaces, unless the report type indicates otherwise." But none of the report types are documented (again see bug amzn/selling-partner-api-models#378) so it's unclear whether this is intentional or not. It may well be that GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL intentionally "indicates otherwise", but we won't know until the reports are documented.

moltar commented 3 years ago

Right, and it's not indicated otherwise. Which means there's a bug either in the implementation or documentation.

If it behaved this was since MWS it probably won't change any time soon.

But what's not clear is how is the data grouped. Is it grouped by region? By authorization? By Merchant ID across all regions?

moltar commented 3 years ago

Also, if marketplaceIds parameter is omitted from the request, then an error is thrown:

{
    "errors": [
        {
            "code": "InvalidInput",
            "message": "One or more required parameters missing",
            "details": "marketplaceIds;"
        }
    ]
}

Which definitely supports the idea that there is a bug somewhere.

fractalakash commented 3 years ago

When requesting GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL report and specifying a marketplaceIds filter, this filter gets completely ignored and the data from all marketplaces is returned.

E.g. when I request data for A2NODRKZP88ZB9 (Sweden), I get data for Amazon UK.

        {
            "reportType": "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL",
            "processingEndTime": "2021-09-16T10:41:36+00:00",
            "processingStatus": "DONE",
            "marketplaceIds": [
                "A2NODRKZP88ZB9"
            ],
            "reportDocumentId": "amzn1.spdoc.1.3.f5126eb4-b7f7-492f-96d8-ae1ae270d6c0.T2QW7PSJ9YWOIR.2407",
            "reportId": "202862018886",
            "dataEndTime": "2021-09-16T10:25:12+00:00",
            "createdTime": "2021-09-16T10:41:13+00:00",
            "processingStartTime": "2021-09-16T10:41:19+00:00",
            "dataStartTime": "2021-09-16T03:15:36+00:00"
        }

If you download this report, it will contain data for Amazon.co.uk.

screenshot-20210916T193347-gd39TYOn

Relevant: amzn/selling-partner-api-models#1337, amzn/selling-partner-api-models#1847

@moltar How did you download the report using report document id? Do you know how to download the file from encrypted url using python?

johnkw commented 3 years ago

@fractalakash please delete the above comment which has nothing to do with this ticket. See the reports_2021-06-30.md docs for that general information.

jperestrelo commented 3 years ago

I have the same need but with the reportType GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE. I need to get the report every month per marketplace so I can integrate it with accounting software. Since there isn´t a way to filter by the marketplaceId and also GET /reports/2021-06-30/reports/{reportId} response doesn´t mention the marketplaceId. What would be the recommended way to get one report per marketplace? I would have to create the report specifying what I want using POST /reports/2021-06-30/reports? That's how the API is intended to be used?

thanks in advance,

chrizi42 commented 2 years ago

Any news on this? We still get all orders from all marketplaces.

discover59 commented 2 years ago

I think amazon won't update it because it'll affect integrations for lots of web services. IMO, SP API should make marketplaceIds field optional for this report as this report is a regional report(NA, EU and FE).

FYI, @salric @mentiaa @rickdeee

discover59 commented 2 years ago

@jlevers Would you share your thought about uniqueness of a pair of amazon_order_id, sku and sales_channel? order item id doesn't exist in this report. Is there any report for getting order lines? Thanks.

jlevers commented 2 years ago

I believe that Amazon order ID, SKU, and sales channel should be unique together. I've written code based on that assumption and so far have not run into any issues. I haven't found any reports that give you the order item ID.

Also, just want to note that this comment of mine from 2021 is not correct. I think the official documentation had something in it at the time which said this was true, but it definitely is not.

With the SP API, all regions are accessible with the same auth creds, so I'm not sure if that's true anymore.

Again, that is not true. You need a separate set of credentials for each region.

discover59 commented 2 years ago

Thanks for sharing your thought @jlevers ! Based on my investigation, there are rare cases with multiple rows of same order id, sku and sales channel in a report. Is your library good for handling it?

jlevers commented 2 years ago

My library will handle the document retrieval and parsing for you, but you'll still have to check for duplicate order items yourself -- my library doesn't do anything with the contents of a given report after parsing them to a standardized format.

moltar commented 2 years ago

@discover59 could you provide an example of that please? thx

discover59 commented 2 years ago

@moltar I cannot share the records, but it happens from time to time. IMO, it happens on FBA orders.

github-actions[bot] commented 2 years 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.

moltar commented 1 year ago

Not stale.

GitHub stale bot considered harmful

github-actions[bot] commented 1 year 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 1 year ago

closed for inactivity

AndrewChau commented 1 year ago

I'm getting the same issue GET_V2_SETTLEMENT_REPORT_DATA_XML in https://developer-docs.amazon.com/sp-api/docs/reports-api-v2020-09-01-reference

When you look at the marketplaceIds of the report in the response, you get a list of all the marketplaces (ATVPDKIKX0DER A2EUQ1WTGCTBG2 A2ZV50J4W1RKNI A1MQXOICRS2Z7M A16F3NS8AD5QYS A1AM78C64UM0Y8 AHRY1CZE9ZY4H A3H6HPSLHAK3XG). Maybe all settlement reports are just being associated with all marketplaces.

xEverth commented 10 months ago

The bug is still present as of Jan 2024: All of the marketplaceIds will be returned in the response even when a report is specific to a subset of these marketplaces. There is no way to tell what region, sub-region or market a report is applicable to, and the documentation is not providing this information either. Please resolve asap