A Research Data Repository Service for Managing Metadata Documents based on JSON or XML.
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/api/v1/schemas/my_first_json/validate?version=1' -i -X POST \
-H 'Content-Type: multipart/form-data' \
-F 'document=@metadata-v2.json;type=application/json' \
-F 'version=1'
Same for the HTTP request. The schemaVersion number is set by a query parameter.
POST /api/v1/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=version
1
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=document; filename=metadata-v2.json
Content-Type: application/json
{
"title": "My second 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. (Unfortunately not documented here due to technical reasons.)
HTTP/1.1 422 Unprocessable Entity
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/api/v1/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 /api/v1/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 second 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 » |
---|---|