edoc archive service Administration Guide
Breadcrumbs

What data is sent to my webhook to change values for ECM destination properties before archiving and is expected as a response?

To use webhooks, you must first provide a webhook in an application other than edoc archive service, e.g. in edoc automate.

The webhook must receive information for the following functions and return a corresponding response:

  • Connection test

  • Function of the configured purpose

Define connection tests in webhooks

All types of webhooks use the same details for a connection test.

In addition to the default headers, the header contains the Authorization header if an API key has been configured for the endpoint:

JSON
{
  "Authorization": "Bearer <API Key>"
}


For the connection test, a POST request is sent to the endpoint with the following body:

JSON
{
  "type": "PING"
}


Status code 200 is expected as the response.

Define the webhook for changing values for ECM destination properties during archiving

The following applies to processes whose process types have an endpoint selected for the webhook:

To change values for ECM destination properties during archiving, edoc archive service performs the field mapping of ERP fields to ECM fields for each process. The resulting values for the ECM destination properties are then sent to the webhook together with information about the process using a POST request.

In addition to the default headers, the request header contains the Authorization header if an API key has been configured for the endpoint:

JSON
{
  "Authorization": "Bearer <API Key>"
}


The following data is sent in the body of the request:

  • Type after-attribute-matching

  • An array with data on the process:

    • ID and the name of the configured endpoint for the webhook.

    • All data on the process that is also displayed in the edoc archive service cockpit table.

    • Configured process type for the process.

    • Values for ECM destination properties created by the field mapping of ERP fields to ECM fields.

    • All process data in the ERP system.


Example of the body of a request for a webhook

With a connection to Microsoft Dynamics 365 Business Central or Microsoft Dynamics NAV, the body can look as follows:

JSON
{
	"type": "after-attribute-matching",
    "data": {
		"webhookEndpoint": {
            "id": "123456789-123456789-123456789-123456",
            "name": "After attribute modification webhook for Sales Orders"
        },
		"archiving_process": {
            "data_status": 1,
            "document_status": 1,
            "document_type": 2,
            "ecm_id": "A000000001",
            "ecm_keys": [
            ],
            "erp_entry_number": "123456789-123456789-123456789-123456",
            "erp_system_id": "123456789-123456789-123456789-123456",
            "error_code": "Error 400 - Some error occurred when ...",
            "error_count": 1,
            "file_extension": "PDF",
            "file_name": "SalesOrderConfirmationXYZ",
            "index_sub_table": 37,
            "index_table": 36,
            "index_table_key": "Field1=0(1),Field3=0(101003)",
            "integration_page": 0,
            "linking_instance_id": "123456789-123456789-123456789-123456",
            "process_status": 1,
            "process_type": 1,
            "process_type_id": "123456789-123456789-123456789-123456",
            "process_version": 1,
            "report": 1305
        },
        "process_type": {
            "active": 1,
            "archiving_process": 1,
            "description": "Sales Orders - Confirmations",
            "document_type": 2,
            "id": "123456789-123456789-123456789-123456",
            "index_sub_table": 37,
            "index_table": 36,
            "integration_page": 0,
            "linking_instance_id": "123456789-123456789-123456789-123456",
            "name": "Sales Orders",
            "process_type": 1,
            "reindexing": 0,
            "report": 1305,
            "table_link": "Field(1)=Field(1),Field(3)=Field(3)",
            "versioning": 1
        },
        "attributes": {
            "doc_field[1]": [
                "someFieldContent1.1",
                "someFieldContent1.2"
            ],
            "doc_field[2]": [
                "someFieldContent2"
            ]
        },
        "erp_data": {
            "header": {
                "company": "Company Name",
                "fields": [
                    {
                        "id": 1,
                        "name": "DocumentType",
                        "type": "Option",
                        "value": "Order"
                    },
                    {
                        "id": 3,
                        "name": "No",
                        "type": "Code",
                        "value": "101003"
                    },
                    ...
                ],
                "id": 36,
                "name": "SalesHeader",
                "position": "Document Type=CONST(Order),No.=CONST(101003)",
                "primaryKey": {
                    "fieldCount": 2,
                    "fields": [
                        {
                            "id": 1,
                            "name": "DocumentType",
                            "type": "Option",
                            "value": "Order"
                        },
                        {
                            "id": 3,
                            "name": "No",
                            "type": "Code",
                            "value": "101003"
                        }
                    ]
                },
                "recordId": "Sales Header: Order,101003"
            },
            "id": 1,
            "positions": [
                {
                    "company": "Company name",
                    "fields": [
                        {
                            "id": 1,
                            "name": "DocumentType",
                            "type": "Option",
                            "value": "Order"
                        },
                        {
                            "id": 3,
                            "name": "DocumentNo",
                            "type": "Code",
                            "value": "101003"
                        },
                        {
                            "id": 4,
                            "name": "LineNo",
                            "type": "Integer",
                            "value": 10000
                        },
                        ...
                    ],
                    "id": 37,
                    "name": "SalesLine",
                    "position": "Document Type=CONST(Order),Document No.=CONST(101003),Line No.=CONST(10000)",
                    "primaryKey": {
                        "fieldCount": 3,
                        "fields": [
                            {
                                "id": 1,
                                "name": "DocumentType",
                                "type": "Option",
                                "value": "Order"
                            },
                            {
                                "id": 3,
                                "name": "DocumentNo",
                                "type": "Code",
                                "value": "101003"
                            },
                            {
                                "id": 4,
                                "name": "LineNo",
                                "type": "Integer",
                                "value": 10000
                            }
                        ]
                    },
                    "recordId": "Sales Line: Order,101003,10000"
                }
            ]
        }
    }
}


The values for the ECM properties are generated differently for data synchronizations, as multiple fields are not supported. Values of type string are expected instead of type array:

JSON
{
    "attributes": {
        "doc_field[1]": "someFieldContent1.1, someFieldContent1.2",
        "doc_field[2]": "someFieldContent2"
    }
}


Expected response from the webhook

Status 200 is expected as the response. In the body of the response, the revised ECM properties are expected in the same format as a non-empty array:

JSON
{
    "type": "after-attribute-matching",
    "data": {
        ...
        "attributes": {
            ...
        }
    }
}