Link Search Menu Expand Document
Consortium of European Social Science Data Archives

RESTful HTTP

Trigger validation with curl

This example uses an example document and profile hosted on the CMV GitHub repository.

HOSTNAME=https://cmv.cessda.eu
DOCUMENT_URL=https://raw.githubusercontent.com/cessda/cessda.cmv.core/8d0ea9d6a731fa06bde8c8f2b231c2e974aa7130/src/main/resources/demo-documents/ddi-v25/ukds-2000.xml
PROFILE_URL=https://raw.githubusercontent.com/cessda/cessda.cmv.core/8d0ea9d6a731fa06bde8c8f2b231c2e974aa7130/src/main/resources/demo-documents/ddi-v25/cdc25_profile.xml

# If endpoint is secured with HTTP Basic Auth, add option --user $USERNAME:$PASSWORD
curl -s $HOSTNAME/api/V0/Validation \
  --request 'POST' \
  --header 'accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "document": {
    "uri": "'"$DOCUMENT_URL"'"
  },
  "profile": {
    "uri": "'"$PROFILE_URL"'"
  },
  "validationGateName": "BASIC"
}'

The API can also accept XML that has been embedded in the JSON request. The XML must be properly escaped by a tool like jq in order for the content to be preserved.

DOCUMENT_CONTENT=`curl -s $DOCUMENT_URL | jq -Rs .` # Escaping XML to JSON is still not correct!

curl -s $HOSTNAME/api/V0/Validation \
  --request 'POST' \
  --header 'accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "document": {
    "content": "'"$DOCUMENT_CONTENT"'"
  },
  "profile": {
    "uri": "'"$PROFILE_URL"'"
  },
  "validationGateName": "BASIC"
}'

The API can also take a list of constraints to validate against, rather than a pre-set validation gate.

HOSTNAME=https://cmv.cessda.eu
DOCUMENT_URL=https://raw.githubusercontent.com/cessda/cessda.cmv.core/8d0ea9d6a731fa06bde8c8f2b231c2e974aa7130/src/main/resources/demo-documents/ddi-v25/ukds-2000.xml
PROFILE_URL=https://raw.githubusercontent.com/cessda/cessda.cmv.core/8d0ea9d6a731fa06bde8c8f2b231c2e974aa7130/src/main/resources/demo-documents/ddi-v25/cdc25_profile.xml

# If endpoint is secured with HTTP Basic Auth, add option --user $USERNAME:$PASSWORD
curl -s $HOSTNAME/api/V0/Validation \
  --request 'POST' \
  --header 'accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "document": {
    "uri": "'"$DOCUMENT_URL"'"
  },
  "profile": {
    "uri": "'"$PROFILE_URL"'"
  },
  "constraints": ["MandatoryNodeConstraint", "ControlledVocabularyRepositoryConstraint", "CompilableXPathConstraint"]
}'

Trigger validation with Swagger / OpenAPI 3.0

Please note: There is an integration problem with Swagger and Spring-Boot reported: Swagger does not reuse configured Jackson objectMapper Spring bean

Step 1

Step 1

Step 2

  • Click on endpoint POST /api/V0/Validation (green box)
  • Click on the button Try it out

Step 2

Step 3

Step 3

Step 4

  • Scroll down and see constraint violation messages in the response body
  • If this list is empty, the document is valid

Step 4