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
countrythat is not two capital letters, alimitoutside 1 to 200, or a reportformatother thanpdf,csv,jsonordds. - 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/checksor inside a batch’sgeometries: a type other thanPoint,PolygonorMultiPolygon, malformed coordinates, a polygon that intersects itself or aMultiPolygonwhose parts overlap, aPointwithoutasserted_area_ha, or aPointfor a plot over 4 hectares, which must be sent as a polygon. - A
commodity_idthat does not match a commodity, on the same endpoints, or asupplier_idthat does not match an active supplier in your organization, on the plot endpoints only:POST /v1/checkshas nosupplier_id. - A batch that sends both or neither of
plot_idsandgeometries, or more than 500 items. Both and neither give the same response, withfieldset tonull. - A report request that names both or neither of
check_idandbatch_id(fieldisnull), or addsreport without abatch_id. - A report whose
check_idorbatch_iddoes not match a check or batch in your organization: this is a422, not a404. - A report over a batch that is not
complete, or over a batch with no checks because every item was skipped.fieldisbatch_id. - An invalid pagination
cursor, or a list filter such assupplier_idthat 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
{
"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"
}
]
}{
"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)"
}
]
}{
"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.