|
| 1 | +--- |
| 2 | +title: "SharePoint Asynchronous Metadata Read (AMR) API Reference Guide" |
| 3 | +description: "This article provides in-depth information on how to use the SharePoint AMR API." |
| 4 | +ms.date: 04/18/2024 |
| 5 | +ms.author: ranren |
| 6 | +author: underreview |
| 7 | +manager: dapodean |
| 8 | +audience: ITPro |
| 9 | +ms.subservice: migration-tool |
| 10 | +ms.topic: article |
| 11 | +ms.localizationpriority: high |
| 12 | +ms.collection: |
| 13 | + - SPMigration |
| 14 | + - m365-collaboration |
| 15 | +--- |
| 16 | +# SharePoint Asynchronous Metadata Read (AMR) API Reference Guide |
| 17 | + |
| 18 | +Use this document as the guide when using SharePoint Asynchronous Metadata Read (AMR) API. |
| 19 | + |
| 20 | +AMR API aggregates SharePoint metadata into a manifest package. Use the package for incremental migration, structure creation, post-migration validation, or permission management. |
| 21 | + |
| 22 | +## CSOM and REST |
| 23 | + |
| 24 | +AMR API supports both SharePoint Client Side Object Model (CSOM) and REST. |
| 25 | + |
| 26 | +### Use NuGet Packages with CSOM |
| 27 | + |
| 28 | +To reference the SharePoint Client Side Object Model (CSOM) in your solution, use NuGet packages. |
| 29 | + |
| 30 | +Manage dependencies easily and ensure your solution is using the latest version of the CSOM library with NuGet packages. |
| 31 | + |
| 32 | +Get the latest version of the CSOM package at the [SharePoint Client-side Object Model Libraries](https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM) with the ID `Microsoft.SharePointOnline.CSOM`. |
| 33 | + |
| 34 | +Check [Get to know SharePoint REST service](/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service) for instructions on REST API. |
| 35 | + |
| 36 | +## CreateSPAsyncReadJob method |
| 37 | + |
| 38 | +Creates an AMR job to read all the metadata of the specified SharePoint URL and its children into the specified manifest container. |
| 39 | + |
| 40 | +### CreateSPAsyncReadJob syntax |
| 41 | + |
| 42 | +```csharp |
| 43 | +public SPAsyncReadJobInfo CreateSPAsyncReadJob(String url, |
| 44 | +SPAsyncReadOptions readOptions, |
| 45 | +EncryptionOption encryptionOption, |
| 46 | +string azureContainerManifestUri, |
| 47 | +string azureQueueReportUri) |
| 48 | +``` |
| 49 | + |
| 50 | +### CreateSPAsyncReadJob parameters |
| 51 | + |
| 52 | +#### url |
| 53 | + |
| 54 | +Required. |
| 55 | + |
| 56 | +A **String** value containing the full path URL of the path of the SharePoint List, files/folders, or Document Library **to read**. AMR API returns all the metadata of files, folders, and root objects, **including subfolders and any children content**. |
| 57 | + |
| 58 | +##### Example |
| 59 | + |
| 60 | +This example `url` returns all metadata of Shared Document, and its children: |
| 61 | + |
| 62 | +```http |
| 63 | +https://www.contoso.com/Shared%20Document |
| 64 | +``` |
| 65 | + |
| 66 | +#### readOptions |
| 67 | + |
| 68 | +Required. |
| 69 | + |
| 70 | +A `SPAsyncReadOptions` structure, with `readOption` values specifying the types of metadata to read. |
| 71 | + |
| 72 | +##### IncludeVersions |
| 73 | + |
| 74 | +Optional. |
| 75 | + |
| 76 | +A **Bool** value to indicate if AMR API reads multiple versions of files and List Items. |
| 77 | + |
| 78 | +Default value is `false`. When absent or set to `false`, AMR API only reads the latest version of items. |
| 79 | + |
| 80 | +##### IncludeSecurity |
| 81 | + |
| 82 | +Optional. |
| 83 | + |
| 84 | +A **Bool** value to indicate if AMR API reads Users and Groups information related to a Site. |
| 85 | + |
| 86 | +Default value is `false`. |
| 87 | + |
| 88 | +AMR API reads Users and Groups as Authors or Modifiers as part of the metadata of the objects. |
| 89 | + |
| 90 | +If set to `true`, AMR API reads all Users in Site Collections. When reading multiple Document Libraries under the same Site Collection, the same Users and Group might appear in the read package multiple times. |
| 91 | + |
| 92 | +##### IncludeDirectDescendantsOnly |
| 93 | + |
| 94 | +Optional. |
| 95 | + |
| 96 | +A **Bool** value to indicate if AMR API reads only the metadata of the direct descendants. |
| 97 | + |
| 98 | +Default value is `false`. |
| 99 | + |
| 100 | +If set to `true`, AMR API reads only the metadata of the direct descendants. |
| 101 | + |
| 102 | +Use this `readOption` along with `IncludeSecurity` `readOption` together to improve performance when reading metadata from a Document Library containing large number of items, as described in [Best practice](export-amr-api.md) to avoid slow performance. |
| 103 | + |
| 104 | +##### IncludeExtendedMetadata |
| 105 | + |
| 106 | +Optional. |
| 107 | + |
| 108 | +Default value is `false`. |
| 109 | + |
| 110 | +When set to `false`, AMR API reads basic metadata: |
| 111 | + |
| 112 | +- List |
| 113 | +- Folder |
| 114 | +- File |
| 115 | +- List Item |
| 116 | +- Roles |
| 117 | +- Role Assignments |
| 118 | + |
| 119 | +When set to `true`, AMR API reads all metadata available: |
| 120 | + |
| 121 | +For Files: |
| 122 | + |
| 123 | +- Web Part |
| 124 | +- Web Part personalization |
| 125 | +- Links |
| 126 | +- Version events |
| 127 | +- Event receivers |
| 128 | +- Attachment metadata |
| 129 | + |
| 130 | +For Lists: |
| 131 | + |
| 132 | +- Custom actions |
| 133 | +- List shortcuts |
| 134 | + |
| 135 | +For List Items: |
| 136 | + |
| 137 | +- Comments |
| 138 | +- Documents set links |
| 139 | +- Activities |
| 140 | +- List Item shortcuts |
| 141 | + |
| 142 | +Including extended metadata slows down the read significantly. For file share migrations, keep the default value `false`. Set to `true` only when necessary, for complex migration projects. |
| 143 | + |
| 144 | +##### IncludePermission |
| 145 | + |
| 146 | +Optional. |
| 147 | + |
| 148 | +A **Bool** value to indicate if permissions read is needed. Default value is `false`. |
| 149 | + |
| 150 | +When set to `true`, AMR API reads permission metadata in `RoleAssignments` tags in `Manifest.xml` files. The file includes all distinguished permission metadata for each read SharePoint object, along with property `ScopeId`. |
| 151 | + |
| 152 | +##### StartChangeToken |
| 153 | + |
| 154 | +Optional. |
| 155 | + |
| 156 | +A **Integer** value containing the changeToken item. |
| 157 | + |
| 158 | +By default, when no `StartChangeToken` is provided, `CreateSPAsyncReadJob` method returns all items available, based on the parameters. A `CurrentChangeToken` value is returned every time. |
| 159 | + |
| 160 | +To read only the items that changed since last read, set a `StartChangeToken` in subsequent calls to `CreateSPAsyncReadJob`. Use `CurrentChangeToken` returned from last call as the value of `StartChangeToken`. |
| 161 | + |
| 162 | +AMR API returns an error and stops the read, if it receives an invalid `StartChangeToken` value. |
| 163 | + |
| 164 | +Be careful when using this feature with large number of items. The read job could run for extended duration. AMR API cancels jobs that run over 10 minutes to protect the SharePoint infrastructure. |
| 165 | + |
| 166 | +#### encryptionOption |
| 167 | + |
| 168 | +Optional. |
| 169 | + |
| 170 | +A `EncryptionOption` object, containing the AES-256-CBC Key used to decrypt the output. |
| 171 | + |
| 172 | +By default, AMR API doesn't encrypt the output and event queue. If set with AES-256-CBC Key, AMR API encrypts the output with the key supplied. |
| 173 | + |
| 174 | +See `[EncryptionOption](/dotnet/api/microsoft.sharepoint.client.encryptionoption)` class for details. |
| 175 | + |
| 176 | +#### azureContainerManifestUri |
| 177 | + |
| 178 | +Required. |
| 179 | + |
| 180 | +A **String** value, which is the destination URL of the Azure Blob Storage Container containing the output manifest package. |
| 181 | + |
| 182 | +See [Azure](migration-azure.md) for instructions of using Azure Blob Storage Container in migration. |
| 183 | + |
| 184 | +#### azureQueueReportUri |
| 185 | + |
| 186 | +Required. |
| 187 | + |
| 188 | +A **String** value, which is the URL of the Azure Queue to receive read status messages. |
| 189 | + |
| 190 | +Share `azureQueueReportUri` among different jobs if necessary. AMR API returns `JobID` to identify individual jobs created. |
| 191 | + |
| 192 | +See [Azure](migration-azure.md) for instructions of using Azure Queue in migration. Check [Migration events in Azure Queue](migration-events.md) for types of events. |
| 193 | + |
| 194 | +### CreateSPAsyncReadJob return values |
| 195 | + |
| 196 | +#### Job ID |
| 197 | + |
| 198 | +A **Guid** value, which contains Job ID, the unique identifier of the migration job. The method returns a `null` value, if it fails to create the job. |
| 199 | + |
| 200 | +AMR API generates a `JobEnd` event when it estimates item count for each `url`. Check [Events](migration-events.md) for details. |
| 201 | + |
| 202 | +#### AzureContainerManifest |
| 203 | + |
| 204 | +A **Uri** value that contains the URL to access the Azure Blob Storage Container, which contains the metadata read. |
| 205 | + |
| 206 | +#### JobQueueUri |
| 207 | + |
| 208 | +A **Uri** value that contains the URL of the Azure Queue used for read status. |
| 209 | + |
| 210 | +#### EncryptionKey |
| 211 | + |
| 212 | +A **Byte Array** value that contains the AES-256-CBC Key for decrypting the manifest files and messages in the Azure Queue. |
| 213 | + |
| 214 | +## CreateSPAsyncReadJobWithMultiUrl method |
| 215 | + |
| 216 | +Creates an AMR job to read all the metadata of all SharePoint URLs specified, and their children into the specified manifest container. |
| 217 | + |
| 218 | +### CreateSPAsyncReadJobWithMultiUrl syntax |
| 219 | + |
| 220 | +```csharp |
| 221 | +public SPAsyncReadJobInfo CreateSPAsyncReadJobWithMultiUrl( |
| 222 | + String[] urls, |
| 223 | + SPAsyncReadOptions readOptions, |
| 224 | + EncryptionOption encryptionOption, |
| 225 | + String azureContainerManifestUri, |
| 226 | + String azureQueueReportUri) |
| 227 | +``` |
| 228 | + |
| 229 | +### CreateSPAsyncReadJobWithMultiUrl parameters |
| 230 | + |
| 231 | +See `CreateSPAsyncReadJob` method for details of `readOptions`, `encryptionOption`, `azureContainerManifestUri`, and `azureQueueReportUri`. |
| 232 | + |
| 233 | +#### urls |
| 234 | + |
| 235 | +Required. |
| 236 | + |
| 237 | +A **Uri** **Array** containing the full path URLs of the root paths of the SharePoint Lists, files/folders, or Document Libraries to read. AMR API returns all the metadata of files, folders, and root objects, **including subfolders and any children content**. |
| 238 | + |
| 239 | +Specify multiple URLs when needed. Aggravated call with multiple URLs might improve the performance. See [Performance](export-amr-api.md#performance) for details. |
| 240 | + |
| 241 | +## Errors |
| 242 | + |
| 243 | +### -2146232832 |
| 244 | + |
| 245 | +The changeToken refers to a time before the start of the current change log. |
| 246 | + |
| 247 | +The change log is limited to 60 days immediately before the current date. AMR API returns this error code when the specified `changeToken` refers to a time outside the 60-day window. |
| 248 | + |
| 249 | +### -2147213196 |
| 250 | + |
| 251 | +Operation canceled. |
| 252 | + |
| 253 | +AMR API received a cancellation request from the client and cancels the read operation. |
0 commit comments