Skip to content

Using observable queries with curl

You can explore a live query without writing frontend code. These commands run against the Tasks sample on 127.0.0.1:3000; replace the route with your own query’s route from /.cratis/queries.

Terminal window
curl -i http://127.0.0.1:3000/api/tasks/listing/observe-all-tasks
StatusMeaning
200The source has a current value; data holds it and isReady is true
202No value yet; isReady is false. This is not a failure
403Not authorized, or an emission guard denied the snapshot
503A subscription limit is reached; retry after Retry-After
Terminal window
curl 'http://127.0.0.1:3000/api/tasks/listing/observe-all-tasks?waitForFirstResult=true&waitForFirstResultTimeout=5'

For a pending source, waitForFirstResult=true waits for its first emission. The default wait is 30 seconds; waitForFirstResultTimeout accepts a positive number of seconds up to 120. A timeout answers 408; a source that completes before its first value answers 500. Invalid wait options answer 400. Booleans are case-insensitive (True works), and an unrecognized boolean is rejected, where Arc on .NET ignores it. Arc on .NET also accepts larger timeouts; this server bounds them to avoid retaining unlimited subscriptions.

Terminal window
curl -N -H 'Accept: text/event-stream' http://127.0.0.1:3000/api/tasks/listing/observe-all-tasks

-N turns off buffering. You receive one data: <query result JSON> frame now and one for every change; register a task in another terminal to see the next one. Press Ctrl+C to end the subscription; the server releases the source.

A GET passes arguments in the query string. To send structured arguments to an observable query, use the HTTP QUERY method, which answers with a snapshot.