Exporting, Restoring, Sending and Saving Posts
This section explains how to export, restore, send and save backed-up Microsoft Teams posts.
Request
POST https://<hostname>:4443/v5/RestoreSessions/{restoreSessionId}/organization/teams/{teamId}/posts/action |
Request Headers
The request header must contain an authorization token of the current session.
Request Body
Export Action
To export backed-up posts to an HTML file, the request body must contain the export action. You can specify the following optional action properties:
Property | Type | Description |
---|---|---|
ChannelId | string | Specifies the ID of the channel whose posts you want to export. If you specify this property, you can use the From and To properties to specify a time period for which you want to export posts. You do not need to use this property if you use the Posts property to specify what posts to export. |
From | datetime | Specifies the point in time that defines the start of the period for which you want to export posts. |
To | datetime | Specifies the point in time that defines the end of the period for which you want to export posts. |
Posts | posts | Specifies IDs of posts that you want to export. The posts must reside in the same channel. You do not need to use this property if you use the ChannelId property to specify a channel whose posts to export. |
Request Example 1
The following example shows how to export selected posts to an HTML file.
{ "export": { "posts": [{ "id": 1580918830440 }, { "id": 1740917436550 } ] } } |
Request Example 2
The following example shows how to export posts of the specified channel created within the specified time period.
{ "export": { "ChannelId": "19:94e57dbfaa634f999353b374b69b5800@thread.tacv2", } } |
The request command will export posts to an HTML file and place this file to a temporary folder on the Veeam Backup for Microsoft Office 365 server. After that, the HTML file will be transferred as application/octet-stream media to the client. To download, read, convert to HTML or perform other actions with the octet-stream, use features of programming languages.
|
You can use Swagger UI to download the octet-stream file by clicking the Download action link that server returns in the response body after a successfully completed export operation. |
Restore Action
To restore backed-up posts, the request body must contain the Restore action properties:
Property | Type | Description |
---|---|---|
UserName | string | Specifies the user name that you want to use for authenticating with the organization. This parameter is required if you want to use credentials of a user account for data restore. |
UserPassword | string | Specifies the password of the user account that you want to use for authenticating with the organization. This parameter is required if you want to use credentials of a user account for data restore. |
UserCode | string | Specifies the authentication code. For information about how to obtain the code, see Getting Device Code. This parameter is required if you want to use a device code for data restore. |
ApplicationId | string | Specifies the identification number of an Azure AD application that you want to use for data restore. This parameter is required if you want to use a certificate for data 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 information on how to obtain a string, see Converting Certificate to Base64 String. |
ApplicationCertificatePassword | string | Specifies the password for the SSL certificate that you want to use for data restore. |
ChannelId | string | Specifies the ID of the channel whose posts you want to restore. If you specify this property, you can use the From and To properties to specify a time period for which you want to export posts. |
From | datetime | Specifies the point in time that defines the start of the period for which you want to restore posts. |
To | datetime | Specifies the point in time that defines the end of the period for which you want to restore posts. |
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:
- Get the certificate content from a PFX file.
- 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:
- <path_to_cert> — path to the PFX file that you want to convert to a Base64 string.
- <path_to_file> — path to a file that that will contain the resulting Base64 string. You will be able to copy the Base64 string from the file and provide the string in the body of a request to Veeam Backup for Microsoft Office 365 RESTful API.
For example:
$pfx_cert = get-content 'C:\cert.pfx' -Encoding Byte [System.Convert]::ToBase64String($pfx_cert) | Out-File 'C:\base64.txt' |
Request Example 1
The following example shows how to use a user name and password to restore posts.
{ "Restore": { "UserName": "admin", "UserPassword": "password", "ChannelId": "19:94e57dbfaa634f999353b374b69b5800@thread.tacv2", "From": 2020-09-30T18:25:43.511Z, "To": "2020-10-30T18:25:43.511Z" } } |
Request Example 2
The following example shows how to use a device code to restore posts.
{ "From": 2020-09-30T18:25:43.511Z, "To": "2020-10-30T18:25:43.511Z" |
Request Example 3
The following example shows how to use a certificate to restore posts.
{ "Restore": { "ApplicationId" : <app_id>, "ApplicationCertificate": "MIIKEgIBAzCCCc4GCSqGSIb3DQEHAaCCCb8Eggm7MIIJtzCCBggGCSqGSIb3DQEHAaCCBfkEggX1MIIF8TCCBe0GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAg7S8DZJqMJ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crbAfmDaDdM8n0qonvDola5JVsBBSOBZavEN2v/i1YfP42r9vRTMqXTwICB9A=", "ApplicationCertificatePassword": "xxx", "ChannelId": "19:94e57dbfaa634f999353b374b69b5800@thread.tacv2", "From": 2020-09-30T18:25:43.511Z, "To": "2020-10-30T18:25:43.511Z" } } |
Send Action
To send backed-up posts as attachments in an email message, the request body must contain the send action properties:
Property | Type | Description |
---|---|---|
From | string | Specifies the email address from which the restored posts will be sent. |
To | string | Specifies the email address to which the restored posts will be sent. |
Subject | string | Specifies the subject of the email message used for sending restored posts. |
Text | string | Specifies the body of the email message used for sending restored posts. |
ChannelId | string | Specifies the ID of the channel whose posts you want to send. You do not need to use this property if you use the Posts property to specify what posts to send. |
Posts | posts | Specifies IDs of posts that you want to send in an email message. The posts must reside in the same channel. You do not need to use this property if you use the ChannelId property to specify a channel whose posts to send. |
For example:
{ "send": { "from": "admin@tech.com", "to": "user@tech.com", "subject": "teams recovery", "text": "sent by rest api", "posts": [{ "id": 1580918830440 }, { "id": 1740917436550 } ] } } |
|
If you omit the From property, the default sender email address specified in Veeam Explorer for Microsoft Teams email settings will be used. To specify Veeam Explorer for Microsoft Teams email settings, send the PUT HTTPS request to the /VETEmailSettings URL. For more information, see Editing Notification Settings. |
Save Action
To save backed-up posts, the request body must contain the save action. You can specify the following optional action properties:
Property | Type | Description |
---|---|---|
ChannelId | string | Specifies the ID of the channel whose posts you want to save. You do not need to use this property if you use the Posts property to specify what posts to save. |
Posts | posts | Specifies IDs of posts that you want to save. The posts must reside in the same channel. You do not need to use this property if you use the ChannelId property to specify a channel whose posts to save. |
For example:
{ "save": { "posts": [{ "id": 1580918830440 }, { "id": 1740917436550 } ] } } |
The request command will save posts to MSG files and place the files to a temporary folder on the Veeam Backup for Microsoft Office 365 server. After that, the files will be transferred as application/octet-stream media to the client. To download, read or perform other actions with the octet-stream, use features of programming languages.
|
You can use Swagger UI to download files from the stream by clicking Download action link in the response body. |
Response
The server returns the following response to the client.
Response Codes
A successfully completed operation returns 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 the following data:
- [For export and save actions] Binary data stream
- [For the restore action] Information about operation results
- [For the send action] None
The response body for the restore operation has the following properties:
Property | Type | Description |
---|---|---|
CreatedItemsCount | int | Number of missing items restored from the backup. |
MergedItemsCount | int | Number of changed items restored from the backup. |
FailedItemsCount | int | Number of items for which the restore operation failed. |
SkippedItemsCount | int | Number of items that were not changed or missing in the original location. Such items are skipped during the restore operation. |
Example 1
The following request exports backed-up posts with IDs 1580918830440 and 1740917436550 to an HTML file.
Request: POST https://abc.tech.local:4443/v5/RestoreSessions/380d7caf738d3d9f-268b-435b-93e2-64e70f8032b6/organization/teams/448c5b66-8dcd-4c75-b636-d3b500bce36f/posts/action
Request Header: Authorization: Bearer <Access-Token>
Request Body: { "export": { "posts": [{ "id": 1580918830440 }, { "id": 1740917436550 } ] } }
Response: 200 OK |
Example 2
The following request restores backed-up posts of a channel with the ID 19:94e57dbfaa634f999353b374b69b5800@thread.tacv2.
Request: POST https://abc.tech.local:4443/v5/RestoreSessions/380d7caf738d3d9f-268b-435b-93e2-64e70f8032b6/organization/teams/448c5b66-8dcd-4c75-b636-d3b500bce36f/posts/action
Request Header: Authorization: Bearer <Access-Token>
Request Body: { "Restore": { "UserName": "admin", "UserPassword": "password", "ChannelId": "19:94e57dbfaa634f999353b374b69b5800@thread.tacv2", "From": 2020-09-30T18:25:43.511Z, "To": "2020-10-30T18:25:43.511Z" } }
Response: 200 OK
Response body: { "createdItemsCount": 3, "mergedItemsCount": 2, "failedItemsCount": 0, "skippedItemsCount": 1 } |
Example 3
The following request sends backed-up posts with IDs 1580918830440 and 1740917436550 as attachments in an email message.
Request: POST https://abc.tech.local:4443/v5/RestoreSessions/380d7caf738d3d9f-268b-435b-93e2-64e70f8032b6/organization/teams/448c5b66-8dcd-4c75-b636-d3b500bce36f/posts/action
Request Header: Authorization: Bearer <Access-Token>
Request Body: { "send": { "from": "admin@tech.com", "to": "user@tech.com", "subject": "teams recovery", "text": "sent by rest api", "posts": [{ "id": 1580918830440 }, { "id": 1740917436550 } ] } }
Response: 200 OK |
Example 4
The following request saves backed-up posts with IDs 1580918830440 and 1740917436550.
Request: POST https://abc.tech.local:4443/v5/RestoreSessions/380d7caf738d3d9f-268b-435b-93e2-64e70f8032b6/organization/teams/448c5b66-8dcd-4c75-b636-d3b500bce36f/posts/action
Request Header: Authorization: Bearer <Access-Token>
Request Body: { "save": { "posts": [{ "id": 1580918830440 }, { "id": 1740917436550 } ] } }
Response: 200 OK |