Register/Ingest a Metadata Record with Metadata Document (API v2)

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

Register/Ingest a Metadata Record with Metadata Document (API v2)

The following example shows the creation of the first metadata record and its metadata only providing mandatory fields mentioned above:

metadata-record4json.json:
{
  "titles": [
    {
      "value": "Title of first metadata document",
    }
  ],
  "resourceType": {
    "value": "JSON_Metadata",
    "typeGeneral": "MODEL"
  },
  "relatedIdentifiers": [
    {
      "identifierType": "URL",
      "value": "http://localhost:8040/metastore/api/v2/schemas/my_first_json?version=1",
      "relationType": "HAS_METADATA"
    },
    {
      "identifierType": "URL",
      "value": "https://repo/anyResourceId",
      "relationType": "IS_METADATA_FOR"
    }
  ]
}``` 

metadata.json: { “title”: “My first JSON document” } ``` The schemaId used while registering metadata schema has to be used to link the metadata with the approbriate metadata schema.

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

You can see, that most of the sent metadata schema record is empty. Only schemaId and relatedResource are provided by the user. HTTP-wise the call looks as follows:

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

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

{"id":null,"identifier":null,"creators":[],"titles":[{"id":null,"value":"Title of first JSON metadata document","titleType":null,"lang":null}],"publisher":null,"publicationYear":null,"resourceType":{"id":null,"value":"JSON_Metadata","typeGeneral":"MODEL"},"subjects":[],"contributors":[],"dates":[],"relatedIdentifiers":[{"id":null,"identifierType":"URL","value":"https://repo/anyResourceId","relationType":"IS_METADATA_FOR","scheme":null,"relatedMetadataScheme":null},{"id":null,"identifierType":"URL","value":"http://localhost:8040/metastore/api/v2/schemas/my_first_json?version=1","relationType":"HAS_METADATA","scheme":null,"relatedMetadataScheme":null}],"descriptions":[],"geoLocations":[],"language":null,"alternateIdentifiers":[],"sizes":[],"formats":[],"version":null,"rights":[],"fundingReferences":[],"lastUpdate":null,"state":null,"embargoDate":null,"acls":[]}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=document; filename=metadata.json
Content-Type: application/json

{
"title": "My first JSON document"
}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--

As Content-Type only ‘application/json’ is supported and should be provided. The other headers are typically set by the HTTP client. After validating the provided document, adding missing information where possible and persisting the created resource, the result is sent back to the user and will look that way:

HTTP/1.1 201 Created
Location: http://localhost:8040/metastore/api/v2/metadata/d9c917ee-160e-460c-b169-8f952ab505c7?version=1
ETag: "2079736072"
Content-Type: application/json
Content-Length: 1206

{
  "id" : "d9c917ee-160e-460c-b169-8f952ab505c7",
  "identifier" : {
    "id" : 3,
    "value" : "(:tba)",
    "identifierType" : "DOI"
  },
  "creators" : [ {
    "id" : 3,
    "givenName" : "SELF"
  } ],
  "titles" : [ {
    "id" : 3,
    "value" : "Title of first JSON metadata document"
  } ],
  "publisher" : "SELF",
  "publicationYear" : "2024",
  "resourceType" : {
    "id" : 3,
    "value" : "JSON_Metadata",
    "typeGeneral" : "MODEL"
  },
  "dates" : [ {
    "id" : 3,
    "value" : "2024-11-25T13:50:06Z",
    "type" : "CREATED"
  } ],
  "relatedIdentifiers" : [ {
    "id" : 2,
    "identifierType" : "URL",
    "value" : "https://repo/anyResourceId",
    "relationType" : "IS_METADATA_FOR"
  }, {
    "id" : 3,
    "identifierType" : "URL",
    "value" : "http://localhost:8040/metastore/api/v2/schemas/my_first_json?version=1",
    "relationType" : "HAS_METADATA"
  } ],
  "alternateIdentifiers" : [ {
    "id" : 3,
    "value" : "d9c917ee-160e-460c-b169-8f952ab505c7",
    "identifierType" : "INTERNAL"
  } ],
  "version" : "1",
  "lastUpdate" : "2024-11-25T13:50:06.577Z",
  "state" : "VOLATILE",
  "acls" : [ {
    "id" : 4,
    "sid" : "SELF",
    "permission" : "ADMINISTRATE"
  } ]
}

What you see is, that the datacite record looks different from the original document. All remaining elements received a value by the server. In the header you’ll find a location URL to access the ingested metadata and an ETag with the current ETag of the resource. This value is returned by POST, GET and PUT calls and must be provided for all calls modifying the resource, e.g. POST, PUT and DELETE, in order to avoid conflicts.

« PREVIOUS NEXT »