|
| 1 | +--- |
| 2 | +title: Batch apply model |
| 3 | +ms.author: chucked |
| 4 | +author: chuckedmonson |
| 5 | +manager: pamgreen |
| 6 | +ms.reviewer: ssquires |
| 7 | +audience: admin |
| 8 | +ms.topic: reference |
| 9 | +ms.prod: microsoft-365-enterprise |
| 10 | +search.appverid: |
| 11 | +ms.collection: m365initiative-syntex |
| 12 | +ms.localizationpriority: high |
| 13 | +description: Use REST API to apply a document understanding model to one or more libraries. |
| 14 | +--- |
| 15 | + |
| 16 | +# Batch Apply model |
| 17 | + |
| 18 | +Applies (or syncs) a trained document understanding model to one or more libraries (see [example](rest-applymodel-method.md#examples)). |
| 19 | + |
| 20 | +## HTTP request |
| 21 | + |
| 22 | +```HTTP |
| 23 | +POST /_api/machinelearning/publications HTTP/1.1 |
| 24 | +``` |
| 25 | + |
| 26 | +## URI parameters |
| 27 | + |
| 28 | +None |
| 29 | + |
| 30 | +## Request headers |
| 31 | + |
| 32 | +| Header | Value | |
| 33 | +|--------|-------| |
| 34 | +|Accept|application/json;odata=verbose| |
| 35 | +|Content-Type|application/json;odata=verbose;charset=utf-8| |
| 36 | +|x-requestdigest|The appropriate digest for current site.| |
| 37 | + |
| 38 | +## Request body |
| 39 | + |
| 40 | +| Name | Required | Type | Description | |
| 41 | +|--------|-------|--------|------------| |
| 42 | +|__metadata|yes|string|Set the object meta on the SPO. Always use the value: {"type": "Microsoft.Office.Server.ContentCenter.SPMachineLearningPublicationsEntityData"}.| |
| 43 | +|Publications|yes|MachineLearningPublicationEntityData[]|The collection of MachineLearningPublicationEntityData each of which specifies the model and target document library.| |
| 44 | + |
| 45 | +### MachineLearningPublicationEntityData |
| 46 | + |
| 47 | +| Name | Required | Type | Description | |
| 48 | +|--------|-------|--------|------------| |
| 49 | +|ModelUniqueId|yes|string|The unique ID of the model file.| |
| 50 | +|TargetSiteUrl|yes|string|The full URL of the target library site.| |
| 51 | +|TargetWebServerRelativeUrl|yes|string|The server relative URL of the web for the target library.| |
| 52 | +|TargetLibraryServerRelativeUrl|yes|string|The server relative URL of the target library.| |
| 53 | +|ViewOption|no|string|Specifies whether to set new model view as the library default.| |
| 54 | + |
| 55 | +## Response |
| 56 | + |
| 57 | +| Name | Type | Description| |
| 58 | +|--------|-------|------------| |
| 59 | +|201 Created||This is a customized API to support applying a model to multi document libraries. In the case of partial success, 201 created could still be returned and the caller needs to inspect the response body to understand if the model has been successfully applied to a document library.| |
| 60 | + |
| 61 | +## Response Body |
| 62 | + |
| 63 | +| Name | Type | Description| |
| 64 | +|--------|-------|------------| |
| 65 | +|TotalSuccesses|int|The total number of a model being successfully applied to a document library.| |
| 66 | +|TotalFailures|int|The total number of a model failing to be applied to a document library.| |
| 67 | +|Details|MachineLearningPublicationResult[]|The collection of MachineLearningPublicationResult each of which specifies the detailed result of applying the model to the document library.| |
| 68 | + |
| 69 | +### MachineLearningPublicationResult |
| 70 | + |
| 71 | +| Name | Type | Description| |
| 72 | +|--------|-------|------------| |
| 73 | +|StatusCode|int|The HTTP status code.| |
| 74 | +|ErrorMessage|string|The error message which tells what's wrong when apply the model to the document library.| |
| 75 | +|Publication|MachineLearningPublicationEntityData|It specifies the model info and the target document library.| |
| 76 | + |
| 77 | +### MachineLearningPublicationEntityData |
| 78 | + |
| 79 | +| Name | Type | Description | |
| 80 | +|--------|--------|------------| |
| 81 | +|ModelUniqueId|string|The unique ID of the model file.| |
| 82 | +|TargetSiteUrl|string|The full URL of the target library site.| |
| 83 | +|TargetWebServerRelativeUrl|string|The server relative URL of the web for the target library.| |
| 84 | +|TargetLibraryServerRelativeUrl|string|The server relative URL of the target library.| |
| 85 | + |
| 86 | +## Examples |
| 87 | + |
| 88 | +### Apply a model to the contracts document library in the repository site |
| 89 | + |
| 90 | +In this sample, the ID of the Contoso Contract document understanding model is `7645e69d-21fb-4a24-a17a-9bdfa7cb63dc`. |
| 91 | + |
| 92 | +#### Sample request |
| 93 | + |
| 94 | +```HTTP |
| 95 | +{ |
| 96 | + "__metadata": { |
| 97 | + "type": "Microsoft.Office.Server.ContentCenter.SPMachineLearningPublicationsEntityData" |
| 98 | + }, |
| 99 | + "Publications": { |
| 100 | + "results": [ |
| 101 | + { |
| 102 | + "ModelUniqueId": "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc", |
| 103 | + "TargetSiteUrl": "https://contoso.sharepoint.com/sites/repository/", |
| 104 | + "TargetWebServerRelativeUrl": "/sites/repository", |
| 105 | + "TargetLibraryServerRelativeUrl": "/sites/repository/contracts", |
| 106 | + "ViewOption": "NewViewAsDefault" |
| 107 | + } |
| 108 | + ] |
| 109 | + } |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | + |
| 114 | +#### Sample response |
| 115 | + |
| 116 | +In the response, TotalFailures and TotalSuccesses refers to the number of failures and successes of the model being applies to the specified libraries. |
| 117 | + |
| 118 | +**Status code:** 201 |
| 119 | + |
| 120 | +```JSON |
| 121 | +{ |
| 122 | + "Details": [ |
| 123 | + { |
| 124 | + "ErrorMessage": null, |
| 125 | + "Publication": { |
| 126 | + "ModelUniqueId": "7645e69d-21fb-4a24-a17a-9bdfa7cb63dc", |
| 127 | + "TargetSiteUrl": "https://contoso.sharepoint.com/sites/repository/", |
| 128 | + "TargetWebServerRelativeUrl": "/sites/repository", |
| 129 | + "TargetLibraryServerRelativeUrl": "/sites/repository/contracts", |
| 130 | + "ViewOption": "NewViewAsDefault" |
| 131 | + }, |
| 132 | + "StatusCode": 201 |
| 133 | + } |
| 134 | + ], |
| 135 | + "TotalFailures": 0, |
| 136 | + "TotalSuccesses": 1 |
| 137 | +} |
| 138 | +``` |
| 139 | + |
| 140 | +## See also |
| 141 | + |
| 142 | +[Syntex document understanding model REST API](syntex-model-rest-api.md) |
0 commit comments