Validating Metadata Document (API v2)

A Research Data Repository Service for Managing Metadata Documents based on JSON or XML.

Validating Metadata Document (API v2)

Before an ingest of metadata is made the metadata should be successfully validated. Otherwise the ingest may be rejected. Select the schema and the schemaVersion to validate given document.

metadata-v2.json:
{
"title": "My third JSON document",
"date": "2018-07-02"
}

On a first step validation with the old schema will be done:

 $ curl 'http://localhost:8040/metastore/api/v2/schemas/my_first_json/validate?version=1' -i -X POST \
    -H 'Content-Type: multipart/form-data' \
    -F 'document=@metadata-v2.json;type=application/json'

Same for the HTTP request. The schemaVersion number is set by a query parameter.

POST /metastore/api/v2/schemas/my_first_json/validate?version=1 HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Host: localhost:8040

--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=document; filename=metadata-v3.json
Content-Type: application/json

{
"title": "My third JSON document",
"date": "2018-07-02",
}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--

As a result, you receive 422 as HTTP status and an error message holding some information about the error. (language of the message depends on system language)

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/problem+json
Content-Length: 322

{
  "type" : "about:blank",
  "title" : "Unprocessable Entity",
  "status" : 422,
  "detail" : "400 BAD_REQUEST \"Error validating json!\n$: Eigenschaft 'date' ist im Schema nicht definiert und das Schema lässt keine zusätzlichen Eigenschaften zu\"",
  "instance" : "/metastore/api/v2/schemas/my_first_json/validate"
}

The document holds a mandatory field introduced in the second version of schema. Let’s try to validate with second version of schema. Only version number will be different. (if no query parameter is available the current version will be selected)

$ curl 'http://localhost:8040/metastore/api/v2/schemas/my_first_json/validate' -i -X POST \
    -H 'Content-Type: multipart/form-data' \
    -F 'document=@metadata-v2.json;type=application/json'

Same for the HTTP request.

POST /metastore/api/v2/schemas/my_first_json/validate HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Host: localhost:8040

--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=document; filename=metadata-v2.json
Content-Type: application/json

{
"title": "My third JSON document",
"date": "2018-07-02",
}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--

Everything should be fine now. As a result, you receive 204 as HTTP status and no further content.

HTTP/1.1 204 No Content

« PREVIOUS NEXT »