-
Notifications
You must be signed in to change notification settings - Fork 0
Using JSON:API
Content can be created and updated using Drupal's JSON:API. The account used for this should have role "Data catalogue API user" and include HTTP authentication headers in the request. Also include these headers:
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Create a metadata record (create docs)
Send a POST
request to jsonapi/node/data_set
.
Note that references to other entities are under the relationships
key instead of attributes
. All references are by UUID. Some fields are mandatory. If you try to create a record and leave out a mandatory field, the API will return an error code and the message will say what field is missing.
Example body:
{
"data": {
"type": "node--data_set",
"attributes": {
"title": "Record title",
"body": {
"value": "The details.",
"format": "plain_text"
},
"field_published_date": "2021-05-01",
"field_modified_date": "2022-09-19",
"field_data_quality_issues": "The issues.",
"field_data_set_historical_change": "The historial changes.",
"field_critical_information": 0,
"field_authoritative_info": 1,
"field_high_value_info": 1,
"field_personal_information": 0
},
"relationships": {
"field_series": {
"data": {
"type": "taxonomy_term--data_set_series",
"id": "f0a3462e-da91-4b4d-9a61-947cbcef97dc"
}
},
"field_security_classification": {
"data": {
"type": "taxonomy_term--security_classification",
"id": "092b2674-7ce6-403b-a4cc-97a79df0d952"
}
},
"field_source_system": {
"data": {
"type": "taxonomy_term--data_system",
"id": "89b830d5-ffa1-451e-aa05-cebf3cc1c21c"
}
},
"field_data_set_type": {
"data": {
"type": "taxonomy_term--data_set_type",
"id": "8a63de99-bec9-46df-8336-effac7c10bb1"
}
},
"field_primary_responsibility_org": {
"data": {
"type": "taxonomy_term--organization",
"id": "a7c22a58-e823-40b7-bd2c-4e21427a314b"
}
},
"field_visibility": {
"data": {
"type": "taxonomy_term--organization",
"id": "faba301b-bdf5-4658-abc1-e173b815984f"
}
},
"field_data_sets_used": {
"data": {
"type": "node--data_set",
"id": "ac275bae-dd58-4e53-a6d6-5de5c72d3078"
}
}
}
}
}
Update a metadata record (update docs)
Send a PATCH
request to jsonapi/node/data_set/UUID
. Replace UUID
with the UUID of the node and also include that UUID in the id
property of the body.
Example body which updates the title and changes the moderation state:
{
"data": {
"type": "node--data_set",
"id": "179b8f7a-a9ad-4da9-a457-8d0637c82128",
"attributes": {
"moderation_state": {
"value": "published"
},
"title": "Updated title"
}
}
}