Calling a REST service
Your system sends its request to your own Security Server. The Security Server signs the request and passes it, encrypted, to the provider's Security Server.
Prerequisites:
- Your subsystem is registered in GRG.
- The service owner has granted access rights to your subsystem.
Address structure
https://<your-security-server>:8443/r1/<instance>/<member-class>/<member-code>/<subsystem>/<service-code>/<path>| Part | Meaning |
|---|---|
<your-security-server> | The internal address of your own Security Server |
8443 | The HTTPS access point. For HTTP it is 8080. |
r1 | The REST protocol version |
<instance>/<member-class>/<member-code>/<subsystem> | The subsystem on the provider side |
<service-code> | The service code registered by the provider |
<path> | The path within the service and the query parameters. They reach the provider's service exactly as written. |
The HTTP method (GET, POST, PUT, PATCH, DELETE), the request body, Content-Type, Accept and so on are passed to the provider's service unchanged.
Request headers
| Header | Required | Value |
|---|---|---|
X-Road-Client | Yes | The calling subsystem: GRG/COM/1234567/ZEEL. The provider checks access rights against this value. |
X-Road-Id | No | A unique identifier for the request. If you do not supply one, the Security Server generates it. Generating a UUID yourself makes it easier to correlate your logs. |
X-Road-UserId | No | The identifier of the end user who initiated the request. The provider uses it to record who viewed the data. |
X-Road-Issue | No | The number of the case, application or ticket that is the basis for the request |
The service owner may make X-Road-UserId and X-Road-Issue mandatory. Check their agreement and description.
Example
bash
curl -H "X-Road-Client: GRG/COM/1234567/ZEEL" \
"https://ss.example.internal:8443/r1/GRG/GOV/7654321/LAVLAGAA/orlogo/v1/citizens/AA00112233"| In the example | |
|---|---|
| Consumer | GRG/COM/1234567/ZEEL: the ZEEL subsystem of the member with code 1234567 in class COM |
| Provider | GRG/GOV/7654321/LAVLAGAA: the LAVLAGAA subsystem of the member with code 7654321 in class GOV |
| Service | orlogo |
| Path | /v1/citizens/AA00112233 |
A request with a body:
bash
curl -X POST \
-H "X-Road-Client: GRG/COM/1234567/ZEEL" \
-H "X-Road-UserId: MN/AA00112233" \
-H "Content-Type: application/json" \
-d '{"register":"AA00112233","year":2026}' \
"https://ss.example.internal:8443/r1/GRG/GOV/7654321/LAVLAGAA/orlogo/v1/statements"Response
The service's HTTP status, body and headers are returned unchanged. The Security Server adds the following headers:
| Header | Value |
|---|---|
X-Road-Id | The request identifier. Store it in your log. |
X-Road-Client | The calling subsystem |
X-Road-Service | The service that was called |
X-Road-Request-Id | An identifier generated by the Security Server. It links the message logs on both sides. |
X-Road-Request-Hash | The hash of the request. It confirms that the response belongs to exactly this request. |
Distinguishing errors
An error can come from two different sources:
| How to recognise it | Example | |
|---|---|---|
| Service error | The X-Road-Error header is absent. The status and body are those of the provider's service. | 404 "citizen not found" |
| X-Road error | The X-Road-Error header is present. The body is JSON with the fields type, message and detail. | Server.ServerProxy.AccessDenied |
json
{
"type": "Server.ServerProxy.AccessDenied",
"message": "Request is not allowed: SERVICE:GRG/GOV/7654321/LAVLAGAA/orlogo",
"detail": "0f1c2d3e-…"
}List of types: Error reference.
Things to note
- Timeout. A request passes through two Security Servers and the provider's system. Set a definite timeout in your client.
- Retries. Automatically resend only requests that are safe to repeat, such as
GET. Before repeating aPOST, find out how the provider handles duplicates. - Large files. The Security Server records messages. If you are sending a large attachment, agree a size limit with the provider.
- Confidential data. The address path and query parameters remain in the logs. Send confidential values in the body.
Full protocol specification: X-Road Message Protocol for REST