Conditional requests
To minimize bandwidth usage, the response from /aggregates/ and /projections/ returns the ETag header. You can use the value of this header to make subsequent requests to that resources using the If-None-Match header. If the resource has not changed, the server will return a 304 Not Modified.
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
Date: Tue, 19 Sep 2017 14:04:15 GMT
4
ETag: "eccbc87e4b5ce2fe28308fd9f2a7baf3"
5
...
6
7
{
8
"aggregateId": "..."
9
}
Copied!

Making a conditional request

cURL
Java
C#
Node
1
curl -i \
2
--header "Serialized-Access-Key: <YOUR_ACCESS_KEY>" \
3
--header "Serialized-Secret-Access-Key: <YOUR_SECRET_ACCESS_KEY>" \
4
--header "If-None-Match: \"eccbc87e4b5ce2fe28308fd9f2a7baf3\"" \
5
https://api.serialized.io/aggregates/order/99415be8-6819-4470-860c-c2933558d8d3
Copied!
1
import javax.ws.rs.client.Client;
2
import javax.ws.rs.client.ClientBuilder;
3
import javax.ws.rs.core.UriBuilder;
4
import javax.ws.rs.core.Response;
5
6
Client client = ClientBuilder.newClient();
7
URI apiRoot = URI.create("https://api.serialized.io");
8
9
Response response = client.target(apiRoot)
10
.path("aggregates")
11
.path("order")
12
.path("99415be8-6819-4470-860c-c2933558d8d3")
13
.request()
14
.header("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
15
.header("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
16
.header("If-None-Match", "eccbc87e4b5ce2fe28308fd9f2a7baf3")
17
.get();
Copied!
1
using RestSharp;
2
using System;
3
4
var client = new RestClient("https://api.serialized.io");
5
6
var request = new RestRequest("aggregates/{aggregateType}/{aggregateId}", Method.GET)
7
.AddUrlSegment("aggregateType", "order")
8
.AddUrlSegment("aggregateId", "99415be8-6819-4470-860c-c2933558d8d3")
9
.AddHeader("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
10
.AddHeader("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
11
.AddHeader("If-None-Match", "eccbc87e4b5ce2fe28308fd9f2a7baf3")
12
13
var response = client.Execute(request);
Copied!
1
const axios = require("axios");
2
3
const client = axios.create({
4
baseURL: "https://api.serialized.io",
5
headers: {"Serialized-Access-Key": "<YOUR_ACCESS_KEY>"},
6
headers: {"Serialized-Secret-Access-Key": "<YOUR_SECRET_ACCESS_KEY>"}
7
});
8
9
const params = {
10
headers: {"If-None-Match": "eccbc87e4b5ce2fe28308fd9f2a7baf3"},
11
};
12
13
client.get("aggregates/order/99415be8-6819-4470-860c-c2933558d8d3", params)
14
.then(function (response) {
15
// Handle response
16
})
17
.catch(function (error) {
18
// Handle error
19
});
Copied!
Last modified 2yr ago