Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
Teams
, (opens new window)

Knowledge Base
Results will update as you type.
  • Getting Started
  • Erasure Products
  • Erasure Software Tools
  • Management Portal
    • Blancco Common License
    • Blancco Management Portal Upgrade Wizard
    • Blancco Management Portal Upgrade Wizard for Channel Partners
    • Configure single sign-on with Management Portal
    • Create a custom view to mimic the Management Console's "Summary reporting" feature
    • Feature comparison between Blancco Management Portal and Blancco Management Portal On-Premise
    • How to confirm your Blancco Management Portal erasure client endpoint details?
    • How to create custom views in Management Portal
    • How to recover your Blancco Management Portal account?
    • Management Portal - API
      • API Keys
      • Differences in Report Export API between Management Portal and Blancco Cloud
      • Example scripts for report exporting
      • Exporting reports using Management Portal API
      • Pagination and using cursor as part of Report Export API
    • Transferring Reports from Blancco Cloud to Blancco Management Portal
    • Updating Erasure Client Communications Settings
    • "Upgrade successful" banner shown after logging in to Blancco Cloud
    • Blancco Licensing Bundles
  • Management Portal (On-Premise)
  • Management Console
  • Diagnostics Products
  • Hardware Products
  • Mobile Online Solutions (Inhance) Support
  • General Support Articles
  • Web Store FAQ
  • License Activation
  • Professional Services
    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Example scripts for report exporting

      Example scripts for report exporting

      Jul 25, 2023
      Created dateUpdated dateAffects versionFix version

      21 Jul 2023 

      24 Jul 2023 

      Management PortalN/A

      Description

      This page includes a collection of example scripts which can be used to get introduced with the Blancco Management Portal API endpoints.

      NOTE! The provided scripts are fully experimental and built a single use case scenario in mind and are not meant to be used in a production environment!

      There is no guarantee or warranty that these scripts will work as intended in a customer specific environment.

      Running this script is only recommended in a controlled, non-production environment. Use the provided scripts at your own risk.

      Python

      Requirements:

      • Python
      • Requests library

      This script will export multiple pages of reports one report at a time ("size" parameter set to 1) printing the results and giving a summary after exporting the last page/report.

      The endpoint URL, API key, export filter and other parameters are provided as part of the script and can be modified.

      Example python script to export multiple pages of reports a single report at a time
      import requests
      
      def execute_curl_request(cursor=None):
          url = 'https://api.eu-west-1.blancco.cloud/v1/report/export'
          headers = {
              'Content-Type': 'application/json',
              'X-BLANCCO-API-KEY': 'YOUR-API-KEY'
          }
          data = {
              "filter": {
                  "date": {
                      "gte": "2023-07-01T00:00:00Z"
                  }
              },
              "format": "XML",
              "container": "NONE",
              "size": 1
          }
      
          if cursor:
              url += f"?cursor={cursor}"
      
          response = requests.post(url, headers=headers, json=data)
          return response
      
      def check_and_print_response(response):
          if response.status_code == 200:
              print(response.text)
      
              cursor_header = response.headers.get('x-blancco-cursor')
              return cursor_header, True
          else:
              print("Request failed with status code:", response.status_code)
              return None, False
      
      if __name__ == "__main__":
          cursor = None
          success_count = 0
          failure_count = 0
      
          while True:
              response = execute_curl_request(cursor)
      
              if success_count == 0:
                  print("\n--------------------------------------------------")
      
              new_cursor, success = check_and_print_response(response)
      
              if success:
                  success_count += 1
              else:
                  failure_count += 1
      
              if new_cursor:
                  cursor = new_cursor
              else:
                  break
      
          print("\n--------------------------------------------------")
          print("All matching reports exported. Summary of exported reports:")
          print(f"Successful exports: {success_count}")
          print(f"Failed exports: {failure_count}")
      
      
      , multiple selections available, Use left or right arrow keys to navigate selected items
      bmp-api
      {"serverDuration": 8, "requestCorrelationId": "f0a754480b5049f5aa7df47dc1590687"}