Skip to content
PlotDR
Get started

Validation error

Type
https://plotdr.ch/problems/validation-error
HTTP status
422
Content type
application/problem+json

What it means

The request reached the API but one or more of its values cannot be accepted. Nothing was created or changed.

The response always has an errors array with one entry per problem. Each entry has a message and a field: the dotted path of the value in your request, such as geometry, geometries.0.commodity_id or the query parameter cursor, or null when the problem is the request as a whole. When the body is not valid JSON, field is instead the character offset of the parse error, such as "13", and message is JSON decode error.

title is always Validation error. When the request does not match the schema, detail gives the number of fields that failed; when the API rejects a single value itself, detail repeats that value’s message.

Typical causes

  • A required field is missing, or a value has the wrong type, such as an ID that is not a UUID.
  • A value is outside its allowed format or range: a country that is not two capital letters, a limit outside 1 to 200, or a report format other than pdf, csv, json or dds.
  • The request body is not valid JSON.
  • A plot or check geometry PlotDR cannot screen, on POST /v1/plots, PATCH /v1/plots/{plot_id}, POST /v1/checks or inside a batch’s geometries: a type other than Point, Polygon or MultiPolygon, malformed coordinates, a polygon that intersects itself or a MultiPolygon whose parts overlap, a Point without asserted_area_ha, or a Point for a plot over 4 hectares, which must be sent as a polygon.
  • A commodity_id that does not match a commodity, on the same endpoints, or a supplier_id that does not match an active supplier in your organization, on the plot endpoints only: POST /v1/checks has no supplier_id.
  • A batch that sends both or neither of plot_ids and geometries, or more than 500 items. Both and neither give the same response, with field set to null.
  • A report request that names both or neither of check_id and batch_id (field is null), or a dds report without a batch_id.
  • A report whose check_id or batch_id does not match a check or batch in your organization: this is a 422, not a 404.
  • A report over a batch that is not complete, or over a batch with no checks because every item was skipped. field is batch_id.
  • An invalid pagination cursor, or a list filter such as supplier_id that is not a UUID.

What to do

Correct the values named in errors and send the request again. Sending it unchanged returns the same error. For a batch that is not yet complete, wait for it to finish, then request the report again.

422 responses without this type

A few dashboard actions answer 422 with "type": "about:blank", the title Unprocessable Content, and the reason in detail, without an errors array: removing your own account or the organization’s last admin, opening a password-reset, invitation or email verification link that is invalid or has expired, and choosing a plan that has no price at checkout. An integration using an API key never receives them.

See all problem types.

Examples

A request body that does not match the schema: POST /v1/plots without a commodity_id.
{
  "type": "https://plotdr.ch/problems/validation-error",
  "title": "Validation error",
  "status": 422,
  "detail": "1 field(s) failed validation",
  "instance": "/v1/plots",
  "errors": [
    {
      "field": "commodity_id",
      "message": "Field required"
    }
  ]
}
A rule on one field: POST /v1/checks with a self-intersecting polygon. Here detail repeats the message.
{
  "type": "https://plotdr.ch/problems/validation-error",
  "title": "Validation error",
  "status": 422,
  "detail": "geometry is not a valid GeoJSON shape (e.g. self-intersecting polygon)",
  "instance": "/v1/checks",
  "errors": [
    {
      "field": "geometry",
      "message": "geometry is not a valid GeoJSON shape (e.g. self-intersecting polygon)"
    }
  ]
}
An unknown commodity in the second item of a batch's geometries: POST /v1/batches.
{
  "type": "https://plotdr.ch/problems/validation-error",
  "title": "Validation error",
  "status": 422,
  "detail": "commodity_id does not reference an existing commodity",
  "instance": "/v1/batches",
  "errors": [
    {
      "field": "geometries.1.commodity_id",
      "message": "commodity_id does not reference an existing commodity"
    }
  ]
}

See also: all problem types, theerror handling guide, and theAPI reference.