Performing Bulk Restore of OneDrives

In this article

    You can perform a bulk restore of backed-up OneDrives.

    Request

    POST https://<hostname>:4443/v6/RestoreSessions/{restoreSessionId}/Organization/OneDrives/restore

    Request Headers

    The request header must contain an authorization token of the current session.

    Request Parameters

    The following parameter must be specified in the URL of the request:

    Parameter

    Type

    Description

    restoreSessionId

    string

    Specifies the identification number of the restore session. For more information on how to get this parameter, see Getting Restore Sessions.

    Request Body

    To perform a bulk restore of backed-up OneDrives, the request body must contain the following properties:

    Property

    Type

    Description

    officeUsername

    string

    Specifies the user name that you want to use for authenticating to the Microsoft 365 organization.

    officeUserpassword

    string

    Specifies the password of the user account that you want to use for authenticating to the Microsoft 365 organization.

    onpremisesUsername

    string

    Specifies the user name that you want to use for authenticating to the on-premises organization.

    onpremisesUserpassword

    string

    Specifies the password of the user account that you want to use for authenticating to the on-premises organization.

    skipUnresolved

    boolean

    If set to true, indicates that the restore will skip the unresolved items.

    oneDrives

    oneDrive[]

    Specifies the OneDrives you want to restore.

    documentAction

    string

    Specifies the action that will be performed in case the restore destination contains the restored document. The following values are available:

    • Overwrite
    • Keep

    userCode

    string

    Specifies the authentication code. For more information on how to get a device code, see Getting Device Code.

    This property is required if you want to use a device code for data restore.

    applicationId

    string

    An identification number of the Azure AD application that you want to use for a restore.

    applicationCertificate

    base64

    Specifies the SSL certificate configured for the Azure AD application that you want to use for data restore.

    You must provide the certificate as a Base64 string. For more information on how to obtain a Base64 string, see Converting Certificate to Base64 String.

    applicationCertificatePassword

    string

    A password for the SSL certificate being used.

    Converting Certificate to Base64 String

    If you want to use a certificate to access an Azure AD application, you must provide the certificate as a Base64 string. To obtain a Base64 string, perform the following steps:

    1. Get the certificate content from a PFX file.
    2. Convert the certificate to a Base64 string.

    To do this, you can use the following PowerShell cmdlets:

    $pfx_cert = get-content '<path_to_cert>' -Encoding Byte

    [System.Convert]::ToBase64String($pfx_cert) | Out-File '<path_to_file>'

    where:

    For example:

    $pfx_cert = get-content 'C:\cert.pfx' -Encoding Byte

    [System.Convert]::ToBase64String($pfx_cert) | Out-File 'C:\base64.txt'

    Response

    The server returns the following response to the client.

    Response Codes

    A successfully completed operation returns a response code 200 OK.

    Response Headers

    The response to this request contains the following headers. The response may also include additional standard HTTPS headers.

    Header

    Description

    Content-length

    The length of the response body.

    Content-type

    The media type and syntax of the response body message for the requests with the export and save actions: application/octet-stream.

    The media type and syntax of the response body message for the requests with the restore and send actions: null.

    Response Body

    In the response body, the server returns information about operation results. The response body contains the following properties:

    Property

    Type

    Description

    failedRestrictionsCount

    integer

    Specifies the number of items for which restore of permissions failed during the restore operation.

    restoreIssues

    Array of string values

    Description of issues that occurred during the restore operation.

    Example

    The example shows how to restore backed-up organization OneDrives.

    Request:

    POST https://abc.tech.local:4443/v6/RestoreSessions/9bd48e15-5138-4bbc-a030-e053ee2c311e/Organization/OneDrives/restore

     

    Request Header:

    Authorization: Bearer <Access-Token>

     

    Request Body:

    {

     "documentAction": "Overwrite",

     "skipUnresolved": true,

     "oneDrives": [

       {

         "id": "1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5",

         "name": "Administrator",

         "url": "http://server/personal/orgUser"

       }

     ],

     "officeUsername": "admin1@abc.onmicrosoft.com",

     "officeUserpassword": "paSSw0rd",

    }

     

    Response:

    200 OK

     

    Response Body:

    {

     "status": "Success",

     "details": [

       {

         "oneDrive": {

           "id": "1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5",

           "name": "Administrator",

           "url": "http://server/personal/orgUser",

           "_links": {

             "self": {

               "href": "/v6/restoresessions/9bd48e15-5138-4bbc-a030-e053ee2c311e/organization/onedrives/1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5"

             },

             "folders": {

               "href": "/v6/restoresessions/9bd48e15-5138-4bbc-a030-e053ee2c311e/organization/onedrives/1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5/folders?parentId=null"

             },

             "allfolders": {

               "href": "/v6/restoresessions/9bd48e15-5138-4bbc-a030-e053ee2c311e/organization/onedrives/1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5/folders"

             },

             "documents": {

               "href": "/v6/restoresessions/9bd48e15-5138-4bbc-a030-e053ee2c311e/organization/onedrives/1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5/documents?parentId=null"

             },

             "alldocuments": {

               "href": "/v6/restoresessions/9bd48e15-5138-4bbc-a030-e053ee2c311e/organization/onedrives/1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5/documents"

             }

           }

         },

         "status": "Success",

         "details": {

           "failedRestrictionsCount": 0,

           "restoreIssues": []

         }

       }

     ]

    }