Skip to main contentIBM Maximo REST API Guide

Batching of Maximo Mbo errors on a REST create/update call

Certain use cases require the REST POST calls to create/update Mbo’s (using Objec Structures) to batch up the errors and not return on first error. This potentially will be good use case in UI’s that leverage the REST apis to show all errors at once to the end user as opposed to showing them one at a time. To acheive this just set the request header `batcherror:1’. This will batch all errors together. A sample is shown below

POST /oslc/os/mxapiasset?lean=1
batcherror: 1

Body:

{
"assetnum":"A100",
"siteid":"BEDFORD",
"assettype":"BLAH",
"location":"BAH"
}

In here, you will find that the asset type and the location are both invalid values. If you submit it without the batcherror:1 header, you will get the usual error json with one error - which probably in this case would be the location error. But for this request, with the said header, the error response would be batched. Sample below shows the batched striucture of the error.

{
"attrerrors":[
{
"Error":{
"errorattrname": "location",
"errorobjpath": "asset",
"reasonCode": "BMXAA2661E",
"message": "BMXAA2661E - Location YES is not a valid location.",
"statusCode": "400"

Now you will figure out that this attrerrors is the added piece that contains the batched array of attribute errors. To be backward compatible, this error also retains the single error block - which can be ignored if you are processing the attrerrors section. Note that there are certain scenarios where this will not work as batch - for example when the error say involves an invalid site or org attrbute value that are part of the primary key.