Reports are generated asynchronously, so creating and retrieving them requires multiple steps. All general API requirements apply.
-
Optional) Determine the product ids or lists needed for the report.
Refer to: “CXH API Guide & Quick Start”
POST https://{hostname}/api/search/productsearch/?skip=0&take=25 HTTP/1.1
Accept-Content: application/json
{
"Archived": false,
"DataOwner": "{{companyId}}",
"Desc": true
}
Or
GET api/report/insights/v2/{companyid}/productlists HTTP/1.1
- (Optional) Determine the websites/retailers to filter the report data.
GET api/report/insights/v2/{companyid}/retailers HTTP/1.1
- Request to generate report
POST https://{hostname}/api/report/insights/v2/{companyid}/reports HTTP/1.1
{
"searchtermids": [],
"productids": [
"b22856f0-391b-6b3e-518a-d55b2de1d1ea"
],
"productlistids": [],
"retailerids": [],
"startdate": "{{date_yesterday}}",
"enddate": "{{date_today}}",
"columnids": {
"Live Site Product": [
"ProductName",
"Brand",
"GTIN"
]
},
"pageoneonly": true,
"format": "csv",
"maxrowsperfile": 10000
}
- Server will return HTTP status 202 Accepted. Response will contain Location header. This endpoint must be polled to determine the report status. Body of response will also include report id.
HTTP/1.1 200 Accepted
Location: https://{hostname}/api/report/insights/v2/{companyid}/reports/status/{reportid}
{
"report_id": "{reportId}"
}
- Poll for the report status using the URL from the Location header received in previous step until it returns either 303 or a 5xx error.
GET https://{hostname}/api/report/insights/v2/{companyid}/reports/status/{reportid} HTTP/1.1
On success, the response will have status 303 and a Location header to retrieve the report download. The body of the response will also contain a list of URLs for each file that was generated.
HTTP/1.1 303 See Other
Location: https://{hostname}/reports/{reportid}.csv?..filename%3D%22{reportid}.csv%22
{
“url”: [“...”, .., “...”]
}
- Fetch the report data using the url from Location header from step 2 or list of URLs found in response body.
GET https://{hostname}/reports/{reportid}.csv?..filename=.. HTTP/1.1