Community

Calling the Vantage API from Microsoft Power Automate

Microsoft Power Automate is a powerful cloud and desktop automation platform. Sometimes its users may need to extract data from various documents, and this is where ABBYY Vantage comes in.

ABBYY Vantage offers a RESTful API, which allows you to access its functionality from external systems. In this post, I’ll show how you can call the ABBYY Vantage API from Microsoft Power Automate.

I assume you have working knowledge of Microsoft Power Automate, so I will skip the basics. If you are not familiar with the platform, I’d recommend that you read this guide first: https://docs.microsoft.com/en-us/power-automate/getting-started 

We will be using two actions:

  • 1. HTTP action to call the API
  • 2. Parse JSON action to process responses

To read about the available methods, please open the Swagger UI:

https://<VantageURL>/api/index.html?urls.primaryName=publicapi%2Fv1

Figure 1. HTTP action from HTTP connector.

The HTTP action has everything you need to call the REST API. These are fields that we’ll be using: Method, URI, Headers, and Body.

Figure 2. Expanded HTTP action.

Authenticating in ABBYY Vantage

The ABBYY Vantage API uses token-based authentication. This means that you need to receive a token first and use it in subsequent calls.
To connect to ABBYY Vantage, you must select POST as the method to be used for the URI.
NOTE: Here and below, <text in brackets> indicates a placeholder for your own data (e.g. URL or credentials).

Method

POST

URI

<VantageURL>/auth/connect/token

Headers: Content-Type

application/x-www-form-urlencoded

Body

grant_type=password&scope=openid&username=<your username>&password=<your password> client_id=ABBYY.Vantage&client_secret=f3ec6136-6ccc-75a1-3780-caeef723e998

Authentication

None

Figure 3. Receiving an authentication token.

In the next step, we need to extract the authentication token from the API response. The response comes in JSON format. To parse the JSON response, we’ll use the Parse JSON action.

Figure 4. Parsing the response with the Parse JSON action.

Schema:

{

    "type": "object",

    "properties": {

        "access_token": {

            "type": "string"

        },

        "expires_in": {

            "type": "integer"

        },

        "token_type": {

            "type": "string"

        },

        "scope": {

            "type": "string"

        }

    }

}

After parsing the response, the “access_token” value will become available.


Calling an ABBYY Vantage skill


To call an ABBYY Vantage skill, we’ll use a combined “run” call to create and start a transaction in one call. Use the following HTTP action:

Method

POST

URI

<VantageURL>/api/publicapi/v1/transactions/run

Headers: Authorization

Bearer <access_token>

Headers: Content-Type

application/json

Body

{

  "skillid": "39458774-39b1-4374-bc5f-4d3a9161a898",

  "file": {

    "content": "<content bytes>",

    "fileName": "<file name>"

  }

}

Authentication

none

 

SkillID is the ID of the Invoice US skill. To find out the IDs of your skills, call <VantageURL>/api/publicapi/v1/skills with cUrl or Swagger UI https://<VantageURL>/api/index.html?urls.primaryName=publicapi%2Fv1

In the next step, we parse the response using the Parse JSON action.

{

    "type": "object",

    "properties": {

        "transactionId": {

            "type": "string"

        }

    }

}

After parsing the response, the “transactionId” value will become available.

Figure 5. Creating a connection and calling a skill.

Getting the processing result

To get the processing results, we need to use an HTTP action with following parameters:

Method

GET

URI

<VantageURL>/api/publicapi/v1/transactions/<transactionId>

Headers: Authorization

Bearer <access_token>

Authentication

none

Parse the response with the Parse JSON action:

{

    "type": "object",

    "properties": {

        "id": {

            "type": "string"

        },

        "status": {

            "type": "string"

        },

        "documents": {

            "type": "array",

            "items": {

                "type": "object",

                "properties": {

                    "id": {

                        "type": "string"

                    },

                    "resultFiles": {

                        "type": "array",

                        "items": {

                            "type": "object",

                            "properties": {

                                "fileId": {

                                    "type": "string"

                                },

                                "fileName": {

                                    "type": "string"

                                },

                                "type": {

                                    "type": "string"

                                }

                            },

                            "required": [

                                "fileId",

                                "fileName",

                                "type"

                            ]

                        }

                    },

                    "businessRulesErrors": {

                        "type": "array"

                    }

                },

                "required": [

                    "id",

                    "resultFiles",

                    "businessRulesErrors"

                ]

            }

        },

        "sourceFiles": {

            "type": "array",

            "items": {

                "type": "object",

                "properties": {

                    "id": {

                        "type": "string"

                    },

                    "name": {

                        "type": "string"

                    }

                },

                "required": [

                    "id",

                    "name"

                ]

            }

        }

    }

}

 

Downloading files

Files can be downloaded using the same HTTP actions. You can place additional conditions on the process. I don’t post the conditions here to save space.

Method

GET

URI

<VantageURL>/api/publicapi/v1/transactions/<transactionId>/files/
<fileID>/download

Headers: Authorization

Bearer <access_token>

Authentication

none

Figure 6. Downloading a file and sending it by e-mail.

 

 

 

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.