Artificial Intelligence and Machine Learning Blogs
Explore AI and ML blogs. Discover use cases, advancements, and the transformative potential of AI for businesses. Stay informed of trends and applications.
cancel
Showing results for 
Search instead for 
Did you mean: 
Ace_D
Discoverer
0 Kudos
381

Overview

SAP BTP Document extraction how to use the trail version UI and how we can leverage the service with the Postman.

The Prerequisites

1.SAP BTP Trail Account

2. Document extraction Service and UI set up in the Trial Account

3.Postman for testing the API Call

4.Python for using the API call

 

SAP BTP Trail Account

Please go through some of the below blogs of setting up the BTP Trial Account

 https://developers.sap.com/tutorials/hcp-create-trial-account

Document extraction Service and UI set up in the Trial Account

Use the Booster available in the trail account and select the Document Extraction Booster.

Ace_D_1-1722408175816.png

Ace_D_3-1722408389286.png

Ace_D_1-1722423894495.png

Once the booster set up is complete we will be able to access the document extraction service and also the UI in our service and instances.

We can directly access the UI of the document Extraction from here.

Once we access the UI service we can see the below screen where we will be logging in with the default Client.

Ace_D_2-1722423917735.png

We can click on the Upload icon (+) to upload the document to extract the information.

Here we will have to select what type of underlying document is whether it is Invoice or Payment Advice etc.

Ace_D_3-1722423967609.pngAce_D_4-1722423978506.png

The selection of document type holds the schema of the data.

For example Invoice document will have header and line items and Other information's.

We can also find the predefined extraction fields already provided by SAP for the Particular Document type.

Lets test the service with the provided UI.

We will upload an Invoice Document and use the service to extract the fields out of it.

Ace_D_5-1722424005780.png

 Now the UI Testing is done lets use this service in our Postman App 

Get the service key from the BTP Cockpit

From service key we will use clientid clientsecret backend url and swagger for the postman connect

Ace_D_0-1722410879837.png

Lets use this Extraction service from the postman

Set up the postman with the authorization first

Copy url value inside uaa JSON node from service key and append query oauth/token?grant_type=client_credentials and pass client_id and client_secret_code into basic auth of postman to get bearer token

Ace_D_4-1722420482118.png

Now we are ready with bearer token to use the service 

Get API call with backend url + Swagger = Overall Link(From service key)

Initial Call to get the client for the Document Extraction Service to get the client

Ace_D_5-1722420877140.png

Lets call the Service to post a document 

We will be using  the Post call with /document/jobs with File and options as mandatory Body Parameters

Here file will be the actual file that we want to extract the data.

Options will be the Fields that we need to extract from the file

Example:

{
"clientId": "default",
"extraction": {
        "headerFields": [
                "paymentTerms",
                 "documentDate",
"taxId"],
 
"lineItems": [
            "description"],
 
 "documentType": "invoice"
}
}
 
Once the call is successful in the backend Job get scheduled so the API call will return Job ID and status Pending.
Ace_D_6-1722421588076.png
After some time again we will do a GET Call with the Job id and it will return the Status of the Document.
Ace_D_7-1722422011889.png

Lets write one small python code to play around document extraction service

We will use python request library to make the API calls

we are doing a Get call on the document extraction service with header as Bearer token to get the list of jobs that are available.

Ace_D_9-1722422933805.png

Ace_D_0-1722423609862.png

Hence we can see all the jobs that are available for the Document Extraction service.

 

1 Comment
gregorw
Active Contributor
0 Kudos

Can you please exchange Trail with the correct spelling Trial?