Skip to content

Use Observable Queries with cURL

This guide shows you how to work with observable query endpoints by using plain HTTP tools such as curl.

Use this when you want to:

  • confirm the current snapshot for an observable query
  • wait for the first payload before the request returns
  • follow a live Server-Sent Events (SSE) stream
  • emulate long polling with repeated HTTP requests

The same approach works for both model-bound and controller-based observable query endpoints.

  • You know the observable query URL you want to call.
  • Your application is running.
  • The endpoint already returns an observable query result (ISubject<T>).

A normal GET request returns the current observable snapshot as JSON.

Terminal window
curl "https://localhost:5001/api/orders/observe-all"

Use this when the observable already has a current value and you only want the latest snapshot once.

If the observable does not have a current value yet, add waitForFirstResult=true.

Terminal window
curl "https://localhost:5001/api/orders/observe-all?waitForFirstResult=true"

The request stays open until the observable produces its first payload or the timeout expires.

The default timeout is 30 seconds. Override it with waitForFirstResultTimeout, expressed in seconds.

Terminal window
curl "https://localhost:5001/api/orders/observe-all?waitForFirstResult=true&waitForFirstResultTimeout=10"

If the timeout expires, Arc returns an HTTP timeout response with a JSON error payload.

To keep the connection open and watch updates continuously, request the endpoint as Server-Sent Events.

Terminal window
curl --no-buffer \
-H "Accept: text/event-stream" \
"https://localhost:5001/api/orders/observe-all"

Each update is sent as an SSE data: frame that contains a serialized QueryResult.

Example output:

data: {"isSuccess":true,"data":[{"id":"...","status":"ready"}],"changeSet":null}
data: {"isSuccess":true,"data":[{"id":"...","status":"shipped"}],"changeSet":null}

Use this when you want a live stream instead of a single JSON response.

If you want repeated snapshot requests instead of a continuous stream, call the endpoint in a loop and wait for the first payload each time.

Terminal window
while true; do
curl --silent \
"https://localhost:5001/api/orders/observe-all?waitForFirstResult=true&waitForFirstResultTimeout=15"
echo
done

This is effectively long polling:

  • each request waits until data is available or the timeout expires
  • the server returns a normal JSON payload
  • the client immediately opens a new request

Use this when SSE is not convenient and you still want blocking snapshot requests from plain HTTP tooling.

GoalRequest style
Get the latest snapshot right nowGET /query
Wait until the first payload existsGET /query?waitForFirstResult=true
Wait with a custom timeoutGET /query?waitForFirstResult=true&waitForFirstResultTimeout=10
Follow live updates continuouslyGET /query with Accept: text/event-stream
Repeated blocking snapshot requestsLong-poll loop with waitForFirstResult=true