Developer Network Portal
guide reference
Search Press ESC to dismiss
Loading...
  • Introduction
  • Overview
    • API location
    • Authentication
    • Requests and responses
    • Status and error codes
  • Getting started
    • Setting up the Python environment
    • Starting the Python shell and configuring its session
    • Authenticating to the platform
  • Managing tasks
    • Fetching a list of all tasks
    • Fetching a list of tasks that are in progress
    • Fetching a list of tasks started after the specified date
    • Fetching a list of tasks completed after the specified date
    • Fetching a list of tasks related to Office 365 backup and recovery
  • Managing activities
    • Fetching a list of all activities
  • Index
  • Legal
  • Privacy
Last updated on Jun 29, 2022. Copyright © Acronis International GmbH
2003-2022
  • Guide
  • Managing tasks
  • Fetching a list of tasks related to Office 365 backup and recovery

Fetching a list of tasks related to Office 365 backup and recovery

  1. Authenticate to the cloud platform via the Python shell.

    The following variables should be available now:

    >>> base_url  # the base URL of the API
    'https://eu2-cloud.acronis.com/api/task_manager/v2'
    >>> auth  # the 'Authorization' header value with the access token
    {'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6ImMwMD...'}
    
  2. Define a variable named filters, and then assign an object with the type key containing the list of types related to Office 365 backup and recovery to this variable:

    >>> filters = {
    ...     'type': [
    ...         'UserMailboxBackup', 'SPBackup', 'ODBackup', 'GSBackupGMail', 'GSBackupGDrive',
    ...         'UserMailboxRestore', 'SPRestore', 'ODRestore', 'GSRestoreGMail', 'GSRestoreGDrive'
    ...     ]
    ... }
    
  3. Send a GET request to the /tasks endpoint:

    >>> response = requests.get(f'{base_url}/tasks', headers=auth, params=filters)
    
  4. Check the status code of the response:

    >>> response.status_code
    200
    

    Status code 200 means that the request was successful.

    A different status code means that an error has occurred. For the details, refer to “Status and error codes”.

    Also, the response body contains the items array of task objects formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'items': [{'cancelRequested': False,
            'cancellable': True,
            'startedAt': '2020-04-22T11:34:03.290396913Z',
            'completedAt': '2020-04-22T11:34:03.290396913Z',
            'type': 'UserMailboxBackup',
            ...}
            ...]}
    
Previous Next
  • Legal
  • Privacy
Last updated on Jun 29, 2022. Copyright © Acronis International GmbH
2003-2022
Back to top