Web API: Asynchronous tasks

Some web API commands can run for a long time depending on how much data they’re dealing with, and hence, are executed asynchronously, meaning that, once invoked, they start the job in a background thread and return immediately.

The response contains a unique identifier for the asynchronous task and information on the task’s running status. This task identifier can then be used to poll the status of the task by querying the /tasks/<task id> API endpoint.

If no task is given, e.g. by querying the /tasks endpoint, a list of all available tasks will be returned.

A running task can be canceled with the cancel=true argument. For example:


This request will ask the operation to cancel and return immediately. Note, however, that it may take some time for the cancellation request to complete, as the running task may be blocking on I/O or in a temporarily non-cancelable state. Polling the task repeatedly with the cancel=true parameter is not a problem, though.

Finished tasks, whether they finished successfully, an error occurred, or were canceled, will be kept in memory for 10 minutes in order to allow their status to be queried. Finished tasks can be explicitly pruned with the prune=true parameter. For example:


Prune has no effect on unfinished tasks.


When the command is invoked, it returns a result such as the following XML-formatted response.

   <description>{command description}</description>
   <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8182/tasks/5.xml" type="application/xml"/>
      <task>Connecting to http://overpass-api.de/api/interpreter...</task>

Or the JSON format:

      "description":"osm download filter: null, bbox: -32.9621,-60.6309,-32.9541,-60.6154",
      "progress" :
          "task" : "Connecting to http://overpass-api.de/api/interpreter...",
          "amount" : 0.0

Note, the atom:link in the XML response and the href property in the JSON response, represent the status polling URL for the specific task ID.

The status attribute will have one of the following values: WAITING, RUNNING, FINISHED, FAILED, CANCELLED.

WAITING means that there are other tasks being run in the thread pool and this one has been scheduled to be run as soon as a spot frees up in the thread pool. The others are self-explanatory.

The content of the task query response varies slightly depending on the task status.

Running tasks may or may not contain a progress indicator. It will depend on the type of task and how far along the task is at the point the response is generated.

   <description> Importing geopackage...</description>
   <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8182/tasks/4.xml" type="application/xml"/>
      <task>Importing into GeoGig repo...</task>

Successfully finished tasks may contain a result summary which is specific to the command executed. The following is an example of the result for a successful OSM import operation.

   <description>Importing geopackage....</description>
   <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8182/tasks/5.xml" type="application/xml"/>

And failed tasks contain an exception report.

   <description>Importing geopackage...</description>
   <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8182/tasks/7.xml" type="application/xml"/>
      <message>Nothing to commit after bea73023a9452a9d64f64264d2911ce1ec2b47f2</message>
         org.locationtech.geogig.api.porcelain.NothingToCommitException: Nothing to commit after bea73023a9452a9d64f64264d2911ce1ec2b47f2
         at org.locationtech.geogig.api.porcelain.CommitOp._call(CommitOp.java:320)
         at org.locationtech.geogig.api.porcelain.CommitOp._call(CommitOp.java:57)
         at org.locationtech.geogig.api.AbstractGeoGigOp.call(AbstractGeoGigOp.java:133)
         at org.locationtech.geogig.osm.internal.OSMImportOp._call(OSMImportOp.java:234)
         at org.locationtech.geogig.osm.internal.OSMImportOp._call(OSMImportOp.java:75)
         at org.locationtech.geogig.api.AbstractGeoGigOp.call(AbstractGeoGigOp.java:133)
         at org.locationtech.geogig.osm.internal.OSMDownloadOp._call(OSMDownloadOp.java:155)
         at org.locationtech.geogig.osm.internal.OSMDownloadOp._call(OSMDownloadOp.java:28)
         at org.locationtech.geogig.api.AbstractGeoGigOp.call(AbstractGeoGigOp.java:133)
         at org.locationtech.geogig.rest.AsyncContext$CommandCall.call(AsyncContext.java:192)
         at java.util.concurrent.FutureTask.run(FutureTask.java:262)

back to top