The management of all master data that takes place via API is in a format defined by JSON API (see: http://jsonapi.org/format/ ).
GET /[master data type]?filter[JWToken]=’ba1af54ec3f014f765e8172f9a86dc2a’optional &filter[[attribute name]]=[attribute value{, …}] HTTP/1.1 Accept: application/vnd.api+json
The possible filters:
More filters can be add using the “&” character.
HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "links": { "self": "http://api.visiblefarm.net/[master data type]" }, "data":[{ "type": "[master data type]", "id": [master data key], "attributes": { [attribute]: [value], … (fields for list-query) }, optional "relationships": { "[name of the relation]": { "data": { "id": [related masterdata key], "type": [related masterdata type] } }, … (other relations) } }, … (other masster data entries) ] }
HTTP/1.1 400 Bad Request Content-Type: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "errors": [{ "status": "[error code]", "source": { "pointer": "/[master data type]" }, "title": "[error label]", "details": "[error description]", }] }
GET /[master data type]/[master data key]?filter[JWToken]=’ba1af54ec3f014f765e8172f9a86dc2a’ HTTP/1.1 Accept: application/vnd.api+json
HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "links": { "self": "http://api.visiblefarm.net/[master data type]" }, "data":[{ "type": "[master data type]", "id": [master data key], "attributes": { [attribute]: [value], … (all of the attributes) }, optional "relationships": { "[name of the relation]": { "data": { "id": [related masterdata key], "type": [related masterdata type] } }, … (other relations) } }], optional "included": [{ "type": [related masterdata type], "id": [related masterdata key], "attributes": { [attribute]: [value], … (fields for list-query) }, optional "relationships": { "[name of the relation]": { "data": { "id": [related masterdata key], "type": [related masterdata type] } }, … (other relations) } }, … (attributes of other related fields for list-view) ] }
POST /[master data type] HTTP/1.1 Content-Type: application/vnd.api+json Accept: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "data":[{ "type": "[master data type]", "attributes": { [attribute]: [value], … (at east the mandatory fields) } }] }
HTTP/1.1 201 Created Content-Type: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "links": { "self": "http://api.visiblefarm.net/[master data type]" }, "data":[{ see: list query }] }
PATCH /[master data type]/[master data key] HTTP/1.1 Content-Type: application/vnd.api+json Accept: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "data":[{ "type": "[master data type]", "id": [master data key], "attributes": { [attribute]: [value], … (the updated fields) } }] }
HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "links": { "self": "http://api.visiblefarm.net/[master data type]/[master data key]" }, "data":[{ see: list query }] }
GET /deletedata?filter[JWToken]=’ba1af54ec3f014f765e8172f9a86dc2a’&filter[[master data type]]=[master data key] HTTP/1.1 Accept: application/vnd.api+json
HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "meta":{ "JWToken": "ba1af54ec3f014f765e8172f9a86dc2a" }, "links": { "self": "http://api.visiblefarm.net/deletedata" }, "data":[{ "type": [master data type], "id": [master data key], }] }