You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

作成日更新日影響を受けるバージョン修正バージョン

 

 

Management Portal

説明

When exporting large data sets using the Report Export API endpoints in the Blancco Management Portal the response is split into multiple separate responses. To achieve this use of a special header as part of the request response named "X-BLANCCO-CURSOR" is required.

This page will explain the pagination in more detail and help with the usage of the cursor to fetch all the data when working with larger data sets.

ページサイズの制限

Default page size is limited to a maximum of 100 reports. If the request returns more reports the data is split into multiple responses and using the cursor is required to fetch all the requested reports.

Page size can also be set as a request parameter within the JSON payload if you are using the "Export Reports (POST)" endpoint. The "size" parameter defines the number of returned reports and allows values between 1-10. As an example using "size" value of 5 returns 5 reports per page and each page of 5 reports needs to be requested separately using the cursor.

カーソルヘッダー

In case the request response return a lot of data it is split into multiple separate request responses. When this happens the request response headers will include a "X-BLANCCO-CURSOR" header with a value similar to "1234567890123,1234a12b-1234-123a-ab1c-123456a1b12c"

x-blancco-cursor: 1234567890123,1234a12b-1234-123a-ab1c-123456a1b12c

If the header is not available on the request response all the (remaining) data was returned within the request. This is how you know you have requested the last available page of data.

APIリクエストにカーソルを含める 

If your initial request return the above mentioned header not all the matching reports were included in the provided response and you will need request the rest of the reports by including the cursor to the next request. When you send your initial Report Export request the first page of data will be provided as the response and further data is fetched using cursor.

In the below example request "size" parameter is set to 1 so executing this request returns a single report and the rest of the matching reports need to be requested using cursors.

レポートのエクスポートリクエスト例
curl --request POST \
  --url https://api.eu-west-1.blancco.cloud/v1/report/export \
  --header 'Content-Type: application/json' \
  --header 'X-BLANCCO-API-KEY: {API_KEY}' \
  --data '{
  "filter": {
    "date": {
      "gte": "2020-07-01T00:00:00Z"
    }
  },
  "format": "XML",
  "container": "NONE",
  "size": 1
}'

The response headers will be similar to below, including the X-BLANCCO-CURSOR header which is going to be used to fetch the next report.

要求応答ヘッダーの例
date: Thu, 20 Jul 2023 12:52:17 GMT
content-type: application/xml;charset=UTF-8
content-length: 4994
apigw-requestid: ABCd1e-2fgHIJk=
vary: Origin
vary: Access-Control-Request-Method
vary: Access-Control-Request-Headers
x-blancco-cursor: 1234567890123,1234a12b-cd1e-1234-a123-1a2345b6789c
content-disposition: attachment; filename=reports.xml
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
cache-control: no-cache, no-store, max-age=0, must-revalidate
pragma: no-cache
expires: 0
x-frame-options: SAMEORIGIN

To get the next page of data (in this case the next individual report) the value of the X-BLANCCO-CURSOR header needs to be included in the next request. There are two possibilities to include the value depending on API endpoint being used:

  1. Include the value as the URL parameter (in the endpoint URL)
  2. Include the value as part of the JSON payload

Some endpoints allow using both options, if both are defined at the same time the URL parameter value will be used.

URLパラメータに値を含める

In order to include the cursor as a URL parameter you need to edit the url you are sending the request to and include "?cursor={CURSOR_VALUE}" to the end of the URL (without the quotes).

Below example shows the updated URL and executing this request exports the next matching report.

カーソルを含むレポートエクスポートのリクエスト例
curl --request POST \
  --url  https://api.eu-west-1.blancco.cloud/v1/report/export?cursor=1234567890123%2C1234a12b-cd1e-1234-a123-1a2345b6789c\
  --header 'Content-Type: application/json' \
  --header 'X-BLANCCO-API-KEY: {API_KEY}' \
  --data '{
  "filter": {
    "date": {
      "gte": "2020-07-01T00:00:00Z"
    }
  },
  "format": "XML",
  "container": "NONE",
  "size": 1
}'

Note that it may be required to use hexadecimal presentation for the comma (%2C in above example) when passed as a URL parameter.

JSONペイロードに値を含める

To include the cursor value in the JSON payload it simply needs to be defined as the value for key named "cursor".

Below example show the updated JSON payload with the cursor key-value pair being included. Executing this request exports the next matching report.

カーソルを含むレポートエクスポートのリクエスト例
curl --request POST \
  --url  https://api.eu-west-1.blancco.cloud/v1/report/export \
  --header 'Content-Type: application/json' \
  --header 'X-BLANCCO-API-KEY: {API_KEY}' \
  --data '{
  "filter": {
    "date": {
      "gte": "2020-07-01T00:00:00Z"
    }
  },
  "format": "XML",
  "container": "NONE",
  "size": 1,
  "cursor": "1234567890123,1234a12b-cd1e-1234-a123-1a2345b6789c"
}'


To fetch the next page of reports the next available X-BLANCCO-CURSOR value needs to be updated either as the URL parameter or to the JSON payload. To export all the matching reports this needs to be repeated until a request doesn't provide the X-BLANCCO-CURSOR header anymore.


  • No labels