mu.semte.ch services use JSON:API. For a more detailed overview of how JSON:API works, see their documentation, but this page will list and explain some examples relevant to our application.
Based on the dataset from the app-mow-registry repository. Contains all types of traffic signs, with a board code, description and picture.
Actual real-world instances of road signs. References the road sign type (from above), the sign's location and some other metadata.
To create a resource, you must send an HTTP POST request to domain.name/[resource]
, in the following format:
{
"data": {
"type": "[resource]",
"attributes": {
"[attribute]": "value"
},
"relationships": {
"[relationship-name]": {
"data": {"type": "[other-relationship-name]", "id": "[other-relationship-id]"}
}
}
}
}
A quick way to send these requests from the commandline is using curl.
If you have a file query.json
with the JSON:API query inside of it, you can use this command to create a new resource:
cat query.json | curl -X POST -H Content-Type:application/vnd.api+json -H Accept:application/json -d@- <http://localhost:8000/[resource]>
In practice you would probably use something like Ember Data, but this can be useful for testing during development.