The JSON API indicates that several errors in an attribute / parameter must be specified separately. What is the best way to handle a single error that includes multiple parameters at once?
For example, suppose the endpoint accepts parameters bid
or fold
, but not both (they are mutually exclusive). What should be the error response if both parameters are represented ( GET /endpoint?bid=100.00&fold=muck
)?
List the error twice, once for each attribute?
{
"errors": [
{
"status": "400",
"source": { "parameter": "bid" },
"detail": "Cannot accept both 'bid' and 'fold' parameters."
},
{
"status": "400",
"source": { "parameter": "fold" },
"detail": "Cannot accept both 'bid' and 'fold' parameters."
}
]
}
Merge Attributes?
{
"errors": [
{
"status": "400",
"source": { "parameter": ["bid", "fold"] },
"detail": "Cannot accept both 'bid' and 'fold' parameters."
}
]
}
Make one higher level error for the whole query?
{
"errors": [
{
"status": "400",
"source": { "pointer": "/data" },
"detail": "Cannot accept both 'bid' and 'fold' parameters."
}
]
}
Another way?
source
share