|
| 1 | +--- |
| 2 | +parser: v2 |
| 3 | +auto_validation: true |
| 4 | +time: 5 |
| 5 | +tags: [tutorial>beginner, topic>machine-learning, topic>artificial-intelligence, topic>cloud, software-product>sap-business-technology-platform, software-product>sap-ai-services, software-product>document-information-extraction, tutorial>free-tier] |
| 6 | +primary_tag: topic>machine-learning |
| 7 | +author_name: Juliana Morais |
| 8 | +author_profile: https://github.com/Juliana-Morais |
| 9 | +--- |
| 10 | + |
| 11 | +# Activate the Instant Learning Feature with Swagger UI |
| 12 | +<!-- description --> Use Swagger UI and the Configuration API to activate the instant learning feature of the Document Information Extraction service, one of the SAP AI Business Services in SAP Business Technology Platform (SAP BTP). |
| 13 | + |
| 14 | +## You will learn |
| 15 | + - How to access and consume the Document Information Extraction APIs via Swagger UI |
| 16 | + - How to use the Configuration API to activate the instant learning feature, see the list of all configurations already created and their scope, and delete configurations |
| 17 | + |
| 18 | +## Intro |
| 19 | +Before using the instant learning feature, you need to activate it. This tutorial shows you how to do that. For more information on how to use the instant learning feature, see [Instant Learning (Premium Edition)](https://help.sap.com/docs/document-information-extraction/document-information-extraction/instant-learning-premium-edition-only) and [Instant Learning (Premium Edition): Best Practices](https://help.sap.com/docs/document-information-extraction/document-information-extraction/instant-learning-premium-edition-best-practices). |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +### Authorize Swagger UI |
| 24 | + |
| 25 | + |
| 26 | +To use a trial account to perform this tutorial, first follow the steps described in [Use Trial to Set Up Account for Document Information Extraction and Get Service Key](cp-aibus-dox-booster-key). |
| 27 | + |
| 28 | +To perform this tutorial using the Free (`free`) service plan or one of the service plans intended for productive use – either Premium Edition (`premium_edition`) or Base Edition (`blocks_of_100`) –, first follow the steps described in [Use Free Tier to Set Up Account for Document Information Extraction and Get Service Key](cp-aibus-dox-free-booster-key). For more information on the service plans available for Document Information Extraction, see [Service Plans](https://help.sap.com/docs/document-information-extraction/document-information-extraction/service-plans). |
| 29 | + |
| 30 | +Next, perform the steps described in [Get OAuth Access Token for Document Information Extraction via Web Browser](cp-aibus-dox-web-oauth-token). |
| 31 | + |
| 32 | +Finally, you need to access and authorize the Document Information Extraction Swagger UI as described below. You'll use Swagger UI to call the Document Information Extraction APIs via any web browser. Swagger UI allows developers to effortlessly interact and try out every single operation an API exposes for easy consumption. For more information, see [Swagger UI](https://swagger.io/tools/swagger-ui/). |
| 33 | + |
| 34 | +To access and authorize the Document Information Extraction Swagger UI, you'll need the following entries from the service key that you created for Document Information Extraction in the tutorials [Use Trial to Set Up Account for Document Information Extraction and Get Service Key](cp-aibus-dox-booster-key) or [Use Free Tier to Set Up Account for Document Information Extraction and Get Service Key] (cp-aibus-dox-free-booster-key): |
| 35 | + |
| 36 | +- `url` |
| 37 | + |
| 38 | +- `swagger` |
| 39 | + |
| 40 | +>You'll find both of these entries **outside** the `uaa` section of the service key. (See the image below.) |
| 41 | +
|
| 42 | +1. To access the Document Information Extraction Swagger UI, copy the `url` value and paste it into a text editor. Then, copy the `swagger` value `/document-information-extraction/v1` and paste it onto the end of the `url` value. Finally, copy the entire string, paste it into the address bar of your web browser, and press **Enter**. |
| 43 | + |
| 44 | + <!-- border --> |
| 45 | + |
| 46 | +2. To be able to use the Swagger UI endpoints, you need to authorize yourself. In the top-right corner, click **Authorize**. |
| 47 | + |
| 48 | + <!-- border --> |
| 49 | + |
| 50 | +3. Copy the `access_token` value created in the tutorial [Get OAuth Access Token for Document Information Extraction Using Any Web Browser](cp-aibus-dox-web-oauth-token) and paste it into a text editor. Move your cursor to the start of the line containing the value and enter **Bearer** followed by a space. Finally, copy the entire string, and paste it into the **Value** field. |
| 51 | + |
| 52 | + ``` |
| 53 | + Bearer <access_token> |
| 54 | + ``` |
| 55 | + |
| 56 | +4. Click **Authorize**, and then click **Close**. |
| 57 | + |
| 58 | + <!-- border --> |
| 59 | +
|
| 60 | + <!-- border --> |
| 61 | +
|
| 62 | +
|
| 63 | +
|
| 64 | +### Test Swagger UI authorizations |
| 65 | +
|
| 66 | +
|
| 67 | +Use the **GET /capabilities** endpoint to check if you now have access to the Document Information Extraction APIs via Swagger UI. |
| 68 | +
|
| 69 | +Click the endpoint name to expand it, click **Try it out**, and then **Execute**. |
| 70 | +
|
| 71 | +<!-- border --> |
| 72 | +
|
| 73 | +<!-- border --> |
| 74 | +
|
| 75 | +You should receive a response like the following: |
| 76 | +
|
| 77 | +<!-- border --> |
| 78 | +
|
| 79 | +>If you get an error response code 401 (Unauthorized), your token is probably incorrect. Check whether you've added the word **`Bearer`**, followed by a space, before the token and whether the token value is complete and has been copied properly from the **`access_token`** value in your service key. |
| 80 | +
|
| 81 | +
|
| 82 | +
|
| 83 | +### Create configuration |
| 84 | +
|
| 85 | +
|
| 86 | +Activate the instant learning feature using the **`enableInstantLearning`** configuration key. |
| 87 | +
|
| 88 | +1. Expand the **POST /configuration** endpoint. |
| 89 | +
|
| 90 | +2. Click **Try it out**. |
| 91 | +
|
| 92 | + <!-- border --> |
| 93 | +
|
| 94 | +3. Enter the following in the **`payload`** field: |
| 95 | +
|
| 96 | + ```JSON |
| 97 | + { |
| 98 | + "value": { |
| 99 | + "enableInstantLearning":"true" |
| 100 | + } |
| 101 | + } |
| 102 | + ``` |
| 103 | +
|
| 104 | + You can also make the following optional entries: |
| 105 | +
|
| 106 | + - Choose the scope of the configuration. If you leave this parameter empty, the tenant scope is used. |
| 107 | + |
| 108 | + - Specify the ID of the client you want to set the configuration for. |
| 109 | + |
| 110 | + - Enter the ID of the tenant that you want to set the configuration for. If you leave this parameter empty, the tenantId sending the request is used. |
| 111 | + |
| 112 | + For more information, see [Create Configuration](https://help.sap.com/docs/document-information-extraction/document-information-extraction/create-configuration). |
| 113 | +
|
| 114 | +
|
| 115 | +4. Click **Execute**. |
| 116 | +
|
| 117 | + <!-- border --> |
| 118 | +
|
| 119 | +You should receive a response like the following: |
| 120 | +
|
| 121 | +<!-- border --> |
| 122 | +
|
| 123 | +You've activated the instant learning feature, and you're now all set to start using it as detailed in [Instant Learning (Premium Edition)](https://help.sap.com/docs/document-information-extraction/document-information-extraction/instant-learning-premium-edition-only). |
| 124 | +
|
| 125 | +Steps 4 and 5 are optional. If you wish, you can complete this tutorial by simply setting them to **Done**. |
| 126 | +
|
| 127 | +
|
| 128 | +
|
| 129 | +### Get configuration (optional) |
| 130 | +
|
| 131 | +
|
| 132 | +See the list of all configurations already created and their scope, including the **`enableInstantLearning`** configuration you've just created. |
| 133 | +
|
| 134 | +1. Expand the **Get /configuration** endpoint. |
| 135 | +
|
| 136 | +2. Click **Try it out**. |
| 137 | +
|
| 138 | + <!-- border --> |
| 139 | +
|
| 140 | +3. Click **Execute**. |
| 141 | +
|
| 142 | + <!-- border --> |
| 143 | +
|
| 144 | +You should receive a response like the following: |
| 145 | +
|
| 146 | +<!-- border --> |
| 147 | +
|
| 148 | +
|
| 149 | +
|
| 150 | +### Delete configuration (optional) |
| 151 | +
|
| 152 | +
|
| 153 | +Do the following to delete the **`enableInstantLearning`** configuration: |
| 154 | +
|
| 155 | +1. Expand the **DELETE /configuration** endpoint. |
| 156 | +
|
| 157 | +2. Click **Try it out**. |
| 158 | +
|
| 159 | + <!-- border --> |
| 160 | +
|
| 161 | +3. Enter the following in the **`payload`** field: |
| 162 | +
|
| 163 | + ```JSON |
| 164 | + { |
| 165 | + "value": [ |
| 166 | + "enableInstantLearning" |
| 167 | + ] |
| 168 | + } |
| 169 | + ``` |
| 170 | +
|
| 171 | +4. Click **Execute**. |
| 172 | +
|
| 173 | + <!-- border --> |
| 174 | +
|
| 175 | +You should receive a response like the following: |
| 176 | +
|
| 177 | +<!-- border --> |
| 178 | +
|
| 179 | +Congratulations, you've completed this tutorial. |
0 commit comments