First call
You will call one REST service from start to finish. In the example, a loan system named ZEEL fetches data from the orlogo service of the LAVLAGAA subsystem. All code is fictitious.
1. Know your identifier
Ask your Security Server administrator for the full identifier of your subsystem. It has four parts:
GRG/COM/1234567/ZEELSee the Identifiers and addressing page for the meaning of each part.
2. Get the service identifier
Get the following two items from the service owner:
- The service identifier:
GRG/GOV/7654321/LAVLAGAA/orlogo - The path and parameters within the service, for example
/v1/citizens/{register-number}. If an OpenAPI description exists, you can download it through the metadata services.
3. Check your access rights
Ask your own Security Server whether this service is open to your subsystem:
curl -H "X-Road-Client: GRG/COM/1234567/ZEEL" \
"http://ss.example.internal:8080/r1/GRG/GOV/7654321/LAVLAGAA/allowedMethods"If orlogo is in the returned list, you have access. If the list is empty, the service owner has not granted access.
4. Make the call
curl -i -H "X-Road-Client: GRG/COM/1234567/ZEEL" \
"http://ss.example.internal:8080/r1/GRG/GOV/7654321/LAVLAGAA/orlogo/v1/citizens/AA00112233"ss.example.internal is the internal address of your Security Server. The provider's address is not written anywhere.
If the call succeeds, the service's response is returned exactly as it is. In addition, the Security Server adds a few headers:
HTTP/1.1 200 OK
Content-Type: application/json
X-Road-Id: 29f4d011-ef25-4f18-bfd0-3a2f0e1c7b1a
X-Road-Client: GRG/COM/1234567/ZEEL
X-Road-Service: GRG/GOV/7654321/LAVLAGAA/orlogo
X-Road-Request-Id: f92591a3-6bf0-49b1-987b-0dd78c034cc3
X-Road-Request-Hash: 14sEri8SmLNy/BzWZ8YqZnWXBDhp1LMmRAmSUV5vSrU3qhbpRvqp3nMFJx6RBxTKVTp8OGJZ…Store X-Road-Id in your own log. In the event of a dispute or an error, you search both parties' records by this identifier.
5. If an error occurs
If the response contains an X-Road-Error header, the error came from the Security Server, not from the service:
{
"type": "Server.ServerProxy.AccessDenied",
"message": "Request is not allowed: SERVICE:GRG/GOV/7654321/LAVLAGAA/orlogo"
}The meaning of each type and how to fix it: Error reference.
When moving to production
http://…:8080is for testing only. In production, connect overhttps://…:8443with your system's certificate. Connection, TLS, ports- Set a timeout on every request. The provider may be slow.
- Distinguish errors by type: if access is denied (
AccessDenied) there is no point retrying, whereas a network error can be retried. Code examples