· View as Markdown

Tasks

Route and trip uploads, and experience publishing, run in the background. They return a task: poll its url until status is completed, then read its items and errors.

Returns the specified task

GET /api/v1/tasks/{id}.json

Returns the current state of an asynchronous task owned by the authenticated user.

Uploads are processed in the background. The upload endpoints return a task, and its id is polled here until status becomes completed.

A completed task reports its outcome through two arrays:

  • items lists the assets that were created, each with an item_type, item_id and item_url
  • errors lists anything that went wrong, each with a machine readable code

Both arrays are always present. An upload that succeeded entirely has an empty errors array, and one that created nothing has an empty items array. When an archive is uploaded, entries are processed independently, so a task can report both created assets and errors for the entries that failed.

Headers

  • x-rwgps-api-key string required
    API key for identifying the client application
  • x-rwgps-auth-token string required
    Authentication token for the user

Parameters

  • id integer path required
    Task ID

Response 200

  • task object
    9 fields
    • id integer
    • user_id integer
    • url string
      API url of the task, to poll until it completes
    • type string
      What kind of work the task performs. gps_file_upload for uploads, experience_package for experience packages
    • status string
      pending until the task has run, then completed
    • created_at date-time
    • updated_at date-time
    • items array of objects
      Assets created by the task. Empty while pending, and empty if nothing was created. A file holding several tracks creates one asset per track
      3 fields
      • item_type string
        Type of the created asset: route or trip for uploads, experience_package for experience packages
      • item_id integer
      • item_url string or null
        API url of the created asset
    • errors array of objects
      Anything that went wrong, one entry per track that could not be imported. Empty when the task succeeded entirely
      5 fields
      • code string
        Machine readable reason. One of duplicate, time_data_missing, no_tracks, empty_file, parse_failed, failed_to_process, weigh_in_failed, build_failed, error
      • message string
        Human readable description, always in English
      • item_type string or null
        Set when the error refers to an existing asset, as for a duplicate
      • item_id integer or null
      • item_url string or null

Errors

  • 401 Unauthorized
  • 404 Task not found
Request
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  https://ridewithgps.com/api/v1/tasks/123.json
Response 200
{
  "task": {
    "id": 123,
    "user_id": 123,
    "url": "https://ridewithgps.com/api/v1/tasks/123.json",
    "type": "gps_file_upload",
    "status": "completed",
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "items": [
      {
        "item_type": "route",
        "item_id": 123,
        "item_url": "https://ridewithgps.com/api/v1/routes/123.json"
      }
    ],
    "errors": [
      {
        "code": "duplicate",
        "message": "This route already exists",
        "item_type": "route",
        "item_id": 123,
        "item_url": "https://ridewithgps.com/api/v1/routes/123.json"
      }
    ]
  }
}