Content

JSON and XML

The Multivers and Boekhoud Gemak WebAPI supports 2 formats to communicate. JSON and XML. This page gives some information on how to use both formats in combination with the WebAPI.

Accept header

An application can specify wich type it wants to receive with the Accept header. Setting this header to 'application/json' will result in a JSON format. When the application sents 'application/xml' as value the received format will be xml. This header should allways be set to ensure the right format is requested.

Content-Type header

The Content-Type header works the same as the accept header. The difference being that the Content-Type header has to be set when the application sents a request with a body. So when either a PUT or POST request is being sent the Content-Type should be set to the format used by the body. This value can either be 'application/json' or 'application/xml'.

The result of a request will also contain a Content-Type header. This time it defines wich format is used for the body of the response. This value should allways be equal to the value given by the Accept header.

URL based content type

Another way to force a type of format is to change the URL. When an URL ends with an extension of one of the formats the API will use that one. Below are 2 examples.

JSONXML
https://localhost/api/AdministrationNVL.json https://localhost/api/AdministrationNVL.xml

The JSON format

JSON stands for Javascript Object Notation. It is a simple format that requires little overhead. A lot of modern applications make use of JSON.
A few keypoints about the JSON standard.

  • Arrays are written in brackets. Objects use curly brackets
  • All items in an array or object are comma separated
  • Objects exist out of key-pair values.
  • All names are written in camelcasing
Below is an example of the json response when sending a request to the AdministrationNVL endpoint

    
    [
        {
            "name": "MVL00124",
            "value": "Voorbeeld bedrijf"
        },
        {
            "name": "MVL00125",
            "value": "Test bedrijf"
        },
        {
            "name": "MVL00126",
            "value": "Extra bedrijf"
        },
        {
            "name": "MVL00127",
            "value": "Demonstratiebedrijf"
        }
    ]
    

More information about the JSON standard including libraries for most programming languages can be found at http://json.org/

The XML format

XML stands for Extensible Markup Language. It is a proven format used in tons of applications and protocols.
A few keypoints about the XML standard.

  • An XML document is build up out of opening en closing tags
  • Every opening tag has a name and optional attributes
  • Every closing tag contains only a name with a forward slash infront of it
  • All names are written in pascal casing
  • Within the two tags is the value. This can be a string, integer, or one or more tags
Below is an example of the xml response when sending a request to the AdministrationNVL endpoint.

    
    <?xml version="1.0" encoding="UTF-8"?>
    <ArrayOfNameValuePair xmlns="http://schemas.datacontract.org/2004/07/UNIT4.Multivers.API.Web.WebApi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <NameValuePair>
            <Name>MVL00124</Name>
            <Value>Voorbeeld bedrijf</Value>
        </NameValuePair>
        <NameValuePair>
            <Name>MVL00125</Name>
            <Value>Test bedrijf</Value>
        </NameValuePair>
        <NameValuePair>
            <Name>MVL00126</Name>
            <Value>Extra bedrijf</Value>
        </NameValuePair>
        <NameValuePair>
            <Name>MVL00127</Name>
            <Value>Demonstratiebedrijf</Value>
        </NameValuePair>
    </ArrayOfNameValuePair>