2023:API Services (Service): Difference between revisions

From Grooper Wiki
Line 530: Line 530:


<code>GET {baseUrl}/api/v1/BatchProcessing/Processes?Verbose={Verbose}</code>
<code>GET {baseUrl}/api/v1/BatchProcessing/Processes?Verbose={Verbose}</code>


This returns a list of all published '''Batch Processes'''.  You must enter <cdoe>True</code> or <code>False</code> for <code>{Verbose}</code>
This returns a list of all published '''Batch Processes'''.  You must enter <cdoe>True</code> or <code>False</code> for <code>{Verbose}</code>

Revision as of 17:31, 14 February 2024

This article is about an older version of Grooper.

Information may be out of date and UI elements may have changed.

202520242023.12023

You can perform Batch processing via REST API web calls by installing API Services.

About

The Grooper REST API (Application Programming Interface) allows for seamless integration between line of business solutions or custom-built software and your existing Grooper repositories and processes. A set of REST API methods allows users to push documents through Grooper Batch Processes and retrieve the results.

For example, using the Grooper REST API you can:

  • Get information about a single Batch or all Batches
  • Create a new Batch
  • Delete a Batch
  • Start or resume a Batch Process
  • Get metadata for a specified Batch Folder.
  • And more!

The first step in using the Grooper REST API is setting up an API endpoint for your 3rd party application to interact with a Grooper Repository. To do this, you will need to install a Grooper service in Grooper Config called API Services.

You must register an API key for the API endpoint to function. The API key is passed in the HTML header, using the following key-value syntax:

apiKey: 00000000-0000-0000-0000-000000000000

Instructions on how to obtain an API key are found in the How to install the Grooper API Services tutorial.

How To

Install the Grooper API Services

  1. In Grooper config click the "Edit Services" button to open the "Service Manager" window.



  1. From the Service Manager window click the "Install" button.
  2. Select the desired repository from the "Repository" dropdown.
  3. Choose API Services.
  4. Click the "OK" button to confirm and open the "API Services" window.



  1. From the "API Services" window add an API key for the API Keys property.
  2. Copy the API endpoint URL from the URL property.
  3. Ensure the Windows service user credentials are correct on the User Name and Password properties.
  4. When finished configuring click the "Execute" button to confirm changes and close the "API Services" window.



  1. In the "Service Manager" window, with the newly created "Grooper API Services" service installed and selected, click the "Start" button.
    • FYI - If everything was configured properly, the "Status" of the service will change from "Stopped" to "Running".

Enable a Grooper API Test Endpoint

When using the Grooper REST API, you may find it helpful to test out certain API calls before you implement them. By turning the Enable Test Endpoint property on, you can expose a Grooper REST API testing interface which you can access by entering the API URL in a browser.

  1. When editing an "API Services" service, in the "API Services" window, set the Enable Test Endpoint property to True.
  2. Copy the API endpoint URL from the URL property.
  3. When finished configuring click the "Execute" button to confirm changes and close the "API Services" window.



  1. Paste the copied URL into a browser of your choice.



From here, you can view and test the various REST API methods available to process documents in Grooper.

Test Endpoints

Be aware this section is a work-in-progress. For more information about each API endpoint, set up a test endpoint and try it out for yourself!

Here, you will find more information about testing the Grooper API endpoints.

  • Note, parameters you can pass with the request are in curly brackets.
  • Example: You would replace {BatchID} with the GUID of a Batch.

Delete Batch

DELETE {baseUrl}/api/v1/BatchProcessing/Batches/{BatchID}


This request will delete a Batch in Grooper. Enter a Batch's GUID to delete it.

Get specific Batch info

GET {baseUrl}/api/v1/BatchProcessing/Batches/{BatchID}


This request will give you information about a Batch in Grooper (its "Id", "Name", "Status" and more property values). Enter the Batch's GUID to return information about it.

  • You will receive a JSON response containing information about the Batch.


See below for an example response:

{
  "Id": "c548fe6c-ef2a-4054-ae80-86ee256f79d1",
  "Name": "2. GetBatchInfo",
  "NodeIndex": 0,
  "NumChildren": 2,
  "ParentId": "a4100c92-a1f2-45fe-a0b2-edc9105f8c47",
  "TypeName": "Grooper.Core.Batch",
  "Created": "/Date(1699383023767-0600)/",
  "CreatedBy": "company\\user",
  "Priority": 3,
  "RootFolderId": "e9145698-224a-44ca-9882-46e7be9227e7",
  "Status": 4,
  "StepNo": -1
}

Get all Batch info

GET {baseUrl}/api/v1/BatchProcessing/Batches/All/All?Level={Level}


The Batches/All call returns information about all production Batches in a Grooper Repository at a specified level.

Entering a {Level} of 0 will return information about all production Batches at all folder levels.

  • This is the most common request but can be computationally inefficient as Grooper must iterated through various nodes to determine if Batches are present at multiple levels in the Production branch.


Entering a {Level} other than 0 will return information about production Batches only at the specified level of the Production branch.

  • This can be more efficient if you expect all your Batches to be at the same level.
  • In the example below, we set {Level} to 2, returning information about the single Batch at the second level of the Production branch.

Get file stream

GET {baseUrl}/api/v1/BatchProcessing/Files/{ItemId}/{FileName}


This request returns information about files in the Grooper file store. You will need to enter two things:

  • The item's GUID (often a Batch Folder's GUID)
  • The file's name (often a file associated with or attached to that Batch Folder)


In this example, {ItemId} was set to the GUID of a Batch Folder and {FileName} was set to the name of an attached PDF.

  • The MIME type and file size for that file was returned.
  • However, this could be used to return any number of things, including the full JSON for the Grooper.DocumentData.json file generated for a Batch Folder after it was extracted.


See below for an example response for a pdf file:

Type: application/pdf, Size: 75922


See below for an example response of a "Grooper.DocumentData.json" file:

{
  "Ch": [
    {
      "__type": "FieldInstance:#Grooper.Core",
      "IxId": "dbe2660c-7f9b-403e-8943-20ac4291810f",
      "Name": "Employee Name",
      "FC": 1
    },
    {
      "__type": "FieldInstance:#Grooper.Core",
      "Val": "5",
      "CI": [
        {
          "Val": "Employee Number",
          "Idx": 107,
          "Len": 15,
          "Loc": {
            "X1": 0.6017,
            "Y1": 2.57,
            "X2": 1.8,
            "Y2": 2.73
          },
          "FC": 1
        }
      ],
      "IxId": "6642fc73-ef99-46db-888c-c4f122f6be00",
      "Idx": 123,
      "Len": 1,
      "Name": "Employee Number",
      "Loc": {
        "X1": 2.7758,
        "Y1": 2.5767,
        "X2": 2.8483,
        "Y2": 2.6967
      },
      "FC": 1
    }
  ],
  "IxId": "8edd322a-882f-4e9f-835a-3e51ef6cd5b7",
  "Name": "Data Model",
  "Loc": {
    "X1": 0.5075,
    "Y1": 0.805,
    "X2": 7.9208,
    "Y2": 6.175
  },
  "FC": 1
}

Get Content Type list

GET {baseUrl}/api/v1/BatchProcessing/ContentTypes


This request returns information about all Content Types (Content Models, Content Categories and Document Types) in your repository.

  • There is no configuration necessary.


See below for an example response:

{
  "Id": "ec23d7c3-6db5-4e7f-ad08-b7578e92636a",
  "Name": "7060 Content Model",
  "NodeIndex": 0,
  "NumChildren": 2,
  "ParentId": "c92afd6f-17be-446d-9da4-37cb259fd533",
  "TypeName": "Grooper.Core.ContentModel",
  "Children": [
    {
      "Id": "ab1b1090-3cb7-47fc-a791-542db5a68f72",
      "Name": "7060 Doc Type",
      "NodeIndex": 1,
      "NumChildren": 0,
      "ParentId": "ec23d7c3-6db5-4e7f-ad08-b7578e92636a",
      "TypeName": "Grooper.Core.DocumentType"
    }
  ]
}

Get folder info for a specific folder

GET {baseUrl}/api/v1/BatchProcessing/Folders/{FolderId}


This will will return information about the folder. Enter a Batch Folder's GUID to return information about it.

  • Notably, its name and "DataIsValid" value are often of use.


Example JSON response if the folder exists:

{
  "Id": "0379d4ba-d67c-4ecc-ba82-f61117bc898c",
  "Name": "Doc Type (1)",
  "NodeIndex": 0,
  "NumChildren": 1,
  "ParentId": "3f1139e4-da29-488e-bed8-f1f381b483c3",
  "TypeName": "Grooper.Core.BatchFolder",
  "DataIsValid": false
}


Example JSON response if an invalid GUID is provided (i.e. the object whose GUID you summited is not a folder):

{
  "Message": "Object with ID '74b475a5-fc58-4e6d-b737-b94f6d0aed4c' is not a Batch Folder."
}


Example JSON response if the folder is not found (i.e. the folder has been deleted or never existed in the first place):

{
  "Message": "Batch Folder with ID '79aa46db-cc9c-4ee0-b15d-0c369b603910' not found."
}

Get info for all folders at a specific level

GET {baseUrl}/api/v1/BatchProcessing/Folders/{ParentId}/Folders?Level={Level}


This request will return information about all folders at a specified level within a specifield folder. Enter the GUID for any parent folder (such as a Batch's root folder's GUID) and the folder level you want to search.

  • You will receive information about all folders at that level, including their GUID id, names, index, "DataIsValid" values and more.


See below for an example response:

[
  {
    "Id": "5256e88d-d032-4d24-ab94-edc43056bca2",
    "Name": "1 (1)",
    "NodeIndex": 0,
    "NumChildren": 1,
    "ParentId": "d754077b-9903-4e79-93da-4ececb3aabaf",
    "TypeName": "Grooper.Core.BatchFolder",
    "DataIsValid": false
  },
  {
    "Id": "7bb14095-28a5-4195-b675-29fafb39eee3",
    "Name": "2 (2)",
    "NodeIndex": 1,
    "NumChildren": 0,
    "ParentId": "d754077b-9903-4e79-93da-4ececb3aabaf",
    "TypeName": "Grooper.Core.BatchFolder",
    "DataIsValid": false
  }
]

Get extracted metadata for a specific document (single instance fields only)

GET {baseUrl}/api/v1/BatchProcessing/Folders/{FolderId}/Metadata


This request returns extracted data for a Batch Folder. Enter a Batch Folder's GUID and you will return two things:

  1. The Batch Folder's "ContentTypeId" value (This is its Document Type's GUID).
  2. A list of key-value pairs for each single instance field extracted for the document.
    • For example, if you extracted a value (000-00-0000) for a "Social Sec Num" field you would see something like the following:
"FieldValues": [
  {
    "Key": "Social Sec Num",
    "Value": "000-00-0000"
  }
]
  • Note: "Key" names for Data Fields in single instance Data Sections are returned using dot notation (e.g. "DataSectionName.DataFieldName")


See below for an example response:

{
  "ContentTypeId": "812c3ce5-8334-47dc-bfb9-3c7be1c86e36",
  "FieldValues": [
    {
      "Key": "Header_Details.GUID",
      "Value": "29F17B36-3B51-41C1-811F-9FF8C91CDEFE"
    },
    {
      "Key": "Header_Details.Invoice_Number",
      "Value": "KRS8974"
    },
    {
      "Key": "Header_Details.Invoice_Date",
      "Value": "01/02/2020"
    },
    {
      "Key": "Header_Details.Invoice_Total",
      "Value": "$834.30"
    },
    {
      "Key": "Header_Details.Remit_To_Address",
      "Value": "123 Main St\r\nCity, ST 99999"
    }
  ]
}

Get page info for a specific folder

GET {baseUrl}/api/v1/BatchProcessing/Folders/{ParentId}/Pages?Recursive={Recursive}


This request returns information about pages in a folder. Enter the GUID for a Batch Folder and either "true" or "false" to indicate if the search is recursive.

  • For the recursive parameter, enter:
    • True if you want all pages from all levels below the Batch Folder
    • False if you want only pages at the given Batch Folder level.


Example when {Recursive} is False.

  • Here, there was only a single page at the selected Batch Folder's level.


Example JSON response when {Recursive} is False.

[
  {
    "Id": "afa2699d-6f71-40d1-9a33-0a3a8a233772",
    "Name": "Page 2",
    "NodeIndex": 1,
    "NumChildren": 0,
    "ParentId": "7d7984d4-ac9f-4742-9dfe-31e96311e403",
    "TypeName": "Grooper.Core.BatchPage",
    "DisplayImage": null,
    "Height": 11,
    "OriginalPageNo": 0,
    "PixelFormat": 0,
    "PrimaryImage": "Grooper.Image.pdf",
    "Width": 8.5
  }
]

Example when {Recursive} is True.

  • Here, there are two pages. One is at level 1 and the other at level 2.


Example JSON response when {Recursive} is False.

[
  {
    "Id": "a5502938-e76e-40e4-a8eb-8f4e44651617",
    "Name": "Page 1",
    "NodeIndex": 0,
    "NumChildren": 0,
    "ParentId": "74df0ea0-6225-4cc8-ae19-316906c3d017",
    "TypeName": "Grooper.Core.BatchPage",
    "DisplayImage": null,
    "Height": 11,
    "OriginalPageNo": 0,
    "PixelFormat": 0,
    "PrimaryImage": "Grooper.Image.pdf",
    "Width": 8.5
  },
  {
    "Id": "afa2699d-6f71-40d1-9a33-0a3a8a233772",
    "Name": "Page 2",
    "NodeIndex": 1,
    "NumChildren": 0,
    "ParentId": "7d7984d4-ac9f-4742-9dfe-31e96311e403",
    "TypeName": "Grooper.Core.BatchPage",
    "DisplayImage": null,
    "Height": 11,
    "OriginalPageNo": 0,
    "PixelFormat": 0,
    "PrimaryImage": "Grooper.Image.pdf",
    "Width": 8.5
  }
]

Get information about a published Batch Process

GET {baseUrl}/api/v1/BatchProcessing/Process?Process={Process}


This will return information about a published Batch Process, including information about each of its child steps.

You may enter one of the following for the {Process} parameter:

  • The published Batch Process's name.
  • A published Batch Process's corresponding working Batch Process's GUID.

You will return information about the current published version in either case.


Example when entering the published Batch Process's name.


Example when entering the working Batch Process's GUID.


Example JSON Response:

{
  "Id": "06a50482-633c-42e1-b455-435a5d4ddae3",
  "Name": "10 - Get Batch Process Info",
  "NodeIndex": 0,
  "NumChildren": 1,
  "ParentId": "b42eb137-326c-4bc0-9b05-048d01673ff9",
  "TypeName": "Grooper.Core.BatchProcess",
  "ParentProcessId": "9a8193fc-efe8-4c36-8b2e-4a4de1df760b",
  "PublishedDate": "/Date(1699453839000-0600)/",
  "Steps": [
    {
      "Id": "7051d45b-5c13-40c0-ba46-64b383e720e9",
      "Name": "Split Pages",
      "NodeIndex": 0,
      "NumChildren": 0,
      "ParentId": "06a50482-633c-42e1-b455-435a5d4ddae3",
      "TypeName": "Grooper.Core.BatchProcessStep",
      "ActivateMode": 0,
      "ActivityType": "Grooper.Activities.SplitPages",
      "FolderLevel": 1,
      "NextStepExpression": "",
      "Scope": 2,
      "ShouldSubmitExpression": "",
      "ThreadPool": null
    }
  ]
}


Error response when an invalid Batch Process name is passed:

{
  "Message": "Invalid Published Process Name."
}


Error response when an invalid Batch Process GUID is passed:

{
  "Message": "Invalid Working Process Id."
}

Get a list of all published Batch Processes

GET {baseUrl}/api/v1/BatchProcessing/Processes?Verbose={Verbose}


This returns a list of all published Batch Processes. You must enter <cdoe>True or False for {Verbose}

  • Verbose=False will return a simple list of published Batch Processes and some information about them (Their "Id", "Name", "ParentId" and more).
  • Verbose=True will return a nested list of published Batch Processes and information about about each of their steps.


Example when using Verbose=False


Example when using Verbose=True

Pause a Batch

GET {baseUrl}/api/v1/BatchProcessing/Batches/{BatchId}/Pause


This request will pause a Batch in production. Enter the Batch's GUID to pause it.

  • The JSON response will be property information about the Batch.
  • Note the "Status" value in the JSON response is "4". A status of "4" indicates the Batch is paused.


See below for an example response:

{
  "Id": "69a5c738-2ae4-4a85-9469-c7185cebffd2",
  "Name": "Invoices 2022-03-15 09:30:44 AM",
  "NodeIndex": 1,
  "NumChildren": 2,
  "ParentId": "9d73e0de-a2a5-449f-8f53-93680b55de37",
  "TypeName": "Grooper.Core.Batch",
  "Created": "/Date(1647354644443-0500)/",
  "CreatedBy": "BIS\\dgreenwood",
  "Priority": 3,
  "RootFolderId": "b169bfa7-2fc6-4ad8-8aeb-2723c303621d",
  "Status": 4,
  "StepNo": 5
}

Start/resume processing on a Batch

GET {baseUrl}/api/v1/BatchProcessing/Batches/{BatchId}/Start


This request will start processing a Batch or otherwise resume processing for a paused Batch. Enter a Batch's GUID to start processing it.

  • The JSON response will be property information about the Batch.
  • Note the "Status" value in the JSON response is "1". A status of "1" indicates the Batch is processing/working.


See below for an example response:

{
  "Id": "69a5c738-2ae4-4a85-9469-c7185cebffd2",
  "Name": "Invoices 2022-03-15 09:30:44 AM",
  "NodeIndex": 1,
  "NumChildren": 2,
  "ParentId": "9d73e0de-a2a5-449f-8f53-93680b55de37",
  "TypeName": "Grooper.Core.Batch",
  "Created": "/Date(1647354644443-0500)/",
  "CreatedBy": "BIS\\dgreenwood",
  "Priority": 3,
  "RootFolderId": "b169bfa7-2fc6-4ad8-8aeb-2723c303621d",
  "Status": 1,
  "StepNo": 5
}