Getting started

Before you can start with the MKG API, you will need to complete a few preparatory tasks. The technical installation must first be completed, and you must have the correct license. After that, you can begin. This article provides you with a step-by-step plan and includes a list of the most important calls.

 


Table of Contents


 

Introduction to the MKG API

With the MKG API, it is possible to connect external programs or software to MKG. This article explains how the MKG API works, what you can use it for, and what support you can expect. Read more

 


 

Preparation Steps for MKG API



Step 1. MKG API Setup Before you can work with the MKG API, the setup must first be completed. This setup includes the installation of Tomcat, the configuration of the API with a new or existing SSL certificate, and the enabling of the new functionality. This guide also includes some troubleshooting tips. Read more

 

Step 2. MKG Exchange License. To connect with the MKG API, you need the MKG Exchange license. This license can be obtained as read only (R) or as full control (CRUD). If you do not have a license, please contact the Sales department.

 

Step 3. API Applications. In MKG, at least one new application must be created in the API Applications module. Our advice is to create a separate API application for each application. For each API application, a key is generated, an API key.

 

Step 4. MKG Users. We recommend creating at least one separate user per API application within MKG, so you can easily modify the authorization later. Also, records created and modified using the API are easier to identify.

  • The user must be 'active', have a complex password, and have access to an administration and a fiscal year.
  • Ensure that the MKG user has sufficient rights to perform the desired calls.

 

Step 5. Check Accessibility. Before starting with the MKG API, check if it is accessible from the browser without certificate errors. You do this by entering the base URL in the browser:

  • {{protocol}}://{{server}}:{{poort}}/mkg/web/v3/MKG

The result should be a login form, with no certificate errors returned by the browser.

 


 

Calls

 

To test the calls below, we recommend using the API platform Postman.



1. API Login

This call allows you to log in to the MKG API. In case of a successful login (HTTP status 200), the call returns a cookie with a JSESSIONID. This must be included in the header of subsequent calls.

POST {{protocol}}://{{server}}:{{poort}}/mkg/static/auth/j_spring_security_check

Headers

  • Content-Type = application/x-www-form-urlencoded
  • Accept = application/json

Body (x-www-form-urlencoded)

j_username:{{username}}
j_password:{{password}}

 

2. Base URL

{{restUrl}} = {{protocol}}://{{server}}:{{poort}}/mkg/web/v3/MKG

 

3. Retrieve a Record (GET)

Once logged in, you can make a data request using a GET request. We illustrate this with an example: reading the relationship table with a parameter, resulting in only 10 records.

GET {{restUrl}}/Documents/rela/?NumRows=10

The following values must be included in the header of this call:

  • The cookie content with the JSESSIONID. This is provided after a successful login.
Cookie: JSESSIONID=[...] 
  • The key of the API application from MKG.
X-CustomerID: {{apikey}} 

 

The result is HTTP status code 200 with a JSON starting with:

{
    "response": {
        "ResultData": [
            {
                "rela": [
                    {

 

4. Modify a Record (PUT)

With a PUT request, it is possible to modify existing data. We illustrate this with an example: changing the memo field of a relationship.

PUT {{restUrl}}/Documents/rela/1/

The following values must be included in the header of this call:

Cookie: JSESSIONID=[...] 
X-CustomerID: {{apikey}} 

The fields to be modified must be included in the body of this call as follows:

{
    "request":{
        "InputData":{
            "rela":[
                {
                    "rela_memo":"New memo text"
                }
            ]
    }
    }
}

 

The result is HTTP status code 200 with a JSON containing the key and the modified field with the updated value:

[...]

    "rela_num": 1,

    "rela_memo": "New memo text"

[...]

 

5. Add a Record (POST)

With a POST request, it is possible to add new data. We illustrate this with an example: creating a relationship.

POST {{restUrl}}/Documents/rela/

The following values must be included in the header of this call:

Cookie: JSESSIONID=[...] 
X-CustomerID: {{apikey}} 

The fields to be filled must be included in the body of this call as follows:

{
    "request": {
        "InputData": {
            "rela": [
                {
                    "rela_naam": "Relationship Name",
                    "rela_www": "www.domainname.eu"
                }
            ]
        }
    }
}

 

The result is HTTP status code 200 with a JSON containing the key and the modified field with the filled fields:

[...]

    "rela_num": *,

    "rela_naam": "Relationship Name",

    "rela_www": "www.domainname.eu"

[...]

 

6. Delete a Record (DEL)

With a DEL request, a record can be deleted. We illustrate this with an example: deleting a relationship.

DEL {{restUrl}}/Documents/rela/1

The following values must be included in the header of this call:

Cookie: JSESSIONID=[...] 
X-CustomerID: {{apikey}} 

 

The result is HTTP status code 200.

 


 

Examples of Calls


Various example calls



Base URL:
{{authUrl}} = {{protocol}}://{{server}}:{{poort}}/mkg/static/auth

{{restUrl}} = {{protocol}}://{{server}}:{{poort}}/mkg/web/v3/MKG

 

Login:
POST {{authUrl}}/j_spring_security_check?j_username={{gebruikersnaam}}&j_password={{wachtwoord}}

Logout:
POST {{authUrl}}/j_spring_security_logout

 

Logged-in User:
GET {{restUrl}}/User

Logged-in administration, fiscal year, and language:
GET {{restUrl}}/Settings?Settings=Administration,FiscalYear,Language

 

GET requests

For each of the calls below, the following values must be included in the header:

Cookie: JSESSIONID=[...]

X-CustomerID: {{apikey}}

 

Possible GET parameters:

FieldList:  Comma-separated list of fields, the values of which are returned.
Filter:  Filter applied to the data.
NumRows:  Maximum number of rows that may be returned as a result.
Sort:  Comma-separated list of fields to sort by. A minus sign before the field indicates descending order.

 

Read endpoint.

GET {{restUrl}}/Documents/rela/

 

Read specific endpoint with known key value.

GET {{restUrl}}/Documents/rela/1/

 

Read endpoint with a limit on the number of results (parameter NumRows).

GET {{restUrl}}/Documents/rela/?NumRows=10

 

Read specific endpoint with specific field value (parameter Filter).

GET {{restUrl}}/Documents/rela?Filter=rela_naam = "MKG Nederland bv"

 

Read specific endpoint with multiple specific field values (parameter Filter).

GET {{restUrl}}/Documents/rela?Filter=rela_actief = true AND rela_plaats = "HENGELO"

 

Read endpoint with a limit on the number of fields in the result (parameter FieldList).

GET {{restUrl}}/Documents/rela?FieldList=rela_num,rela_naam

 

Read endpoint with sorting on a specific field (parameter Sort).

GET {{restUrl}}/Documents/rela?Sort=rela_naam

 

Read endpoint with various parameters.

GET {{restUrl}}/Documents/rela?Filter=rela_actief = true AND rela_plaats = "HENGELO"&NumRows=10&FieldList=rela_num,rela_naam,rela_plaats&Sort=rela_naam

 

Read underlying collection from a specific endpoint.

GET {{restUrl}}/Documents/rela/1/rela_adrs

 

Read underlying collection from a specific endpoint with known key value.

GET {{restUrl}}/Documents/rela/1/rela_adrs/1


Operators when using the Filter parameter:

Operator Filter
= equals the specified value
< less than the specified value
> greater than the specified value
<= less than or equal to the specified value
>= greater than or equal to the specified value
in one of a specified comma-separated list of values
NotIn not one of a specified comma-separated list of values
startswith starts with the specified value
endswith ends with the specified value
contains contains the specified value


Functions when using the Filter parameter on a date field:

Function Filter
= Yesterday equals yesterday
= Today equals today *
= Tomorrow equals tomorrow
= GreaterThanToday in the future *
= LessThanToday in the past *
= Prev7Days in the past 7 days
= Next7Days in the next 7 days
= PrevDays() in the past # days
= NextDays() in the next # days
= PrevWeek in the previous week
= ThisWeek in the current week
= NextWeek in the next week
= PrevWeeks() in the past # weeks
= NextWeeks() in the next # weeks
= PrevMonth in the past month
= ThisMonth in the current month
= NextMonth in the next month
= PrevMonths() in the past # months
= NextMonths() in the next # months
= PrevQuarter in the past quarter
= ThisQuarter in the current quarter
= NextQuarter in the next quarter
= PrevQuarters() in the past # quarters
= NextQuarters() in the next # quarters
= PrevYear in the past year
= ThisYear in the current year
= NextYear in the next year
= PrevYears() in the past # years
= NextYears() in the next # years
= PrevFiscalYear in the past fiscal year
= ThisFiscalYear in the current fiscal year
= NextFiscalYear in the next fiscal year
= PrevFiscalYears() in the past # fiscal years
= NextFiscalYears() in the next # fiscal years


* Optionally, a plus or minus number can be specified here. Examples: sys_dat_aanm = Today(3) --> today plus 3 days

Multiple filters can be combined using the operators AND and OR.

PUT requests

For each of the calls below, the following values must be included in the header:

Cookie: JSESSIONID=[...] 
Content-Type: application/json
X-CustomerID: {{apikey}}


Modify multiple values of a record.

PUT {{restUrl}}/Documents/rela/1/

{
    "request":{
        "InputData":{
            "rela":[
                {
                    "rela_memo":"New memo text"
                }
            ]
        }
    }
}


Modify multiple values of a record in an underlying collection.

PUT {{restUrl}}/Documents/vorh/30220001/vorh_vorr/1

Body:

{
    "request":{
        "InputData":{
            "vorr":[
                {
                    "vorr_oms_1":"Modified description",
                    "vorr_order_aantal":99,
                    "vorr_bruto_prijs_ov":23.45,
                    "vorr_op_nacalculatie":false
                }
            ]
        }
    }
}

 

POST requests


For each of the calls below, the following values must be included in the header:

Cookie: JSESSIONID=[...] 
Content-Type: application/json
X-CustomerID: {{apikey}}

 

 

Create a record.

POST {{restUrl}}/Documents/rela/

Body:

{
    "request":{
        "InputData":{
            "rela":[
                {
                    "rela_naam":"New company name",
                    "rela_memo":"New memo text"
                }
            ]
        }
    }
}


Create a record.

POST {{restUrl}}/Documents/vorr/

Body:

 

 

{
    "request":{
        "InputData":{
            "vorr":[
                {
                    "vorh_num":"30220001",
                    "vorr_oms_1":"New description",
                    "vorr_order_aantal":99,
                    "vorr_bruto_prijs_ov":23.45,
                    "vorr_op_nacalculatie":false
                }
            ]
        }
    }
}

 

 

Create a record in an underlying collection.

 

POST {{restUrl}}/Documents/vorh/30220001/vorh_vorr/

Body:

 

 

{
    "request":{
        "InputData":{
            "vorr":[
                {
                    "vorr_oms_1":"New description",
                    "vorr_order_aantal":99,
                    "vorr_bruto_prijs_ov":23.45,
                    "vorr_op_nacalculatie":false
                }
            ]
        }
    }
}

 

DEL requests


For each of the calls below, the following values must be included in the header:

Cookie: JSESSIONID=[...] 
X-CustomerID: {{apikey}}

 

 

Delete record.

DEL {{restUrl}}/Documents/rela/1


Knowledge Center | Related: