IBM Support

REST API response is not in the specified format if the response code is not 200.

Troubleshooting


Problem

Even though the response format (_format=xml) is specified in the URL parameter, I got the response in the json format when the response code is not 200.

Symptom

1) Confirm that you have the object structure "MXASSET" and the asset record where assetnum is 13150.
2) From the command prompt, run the following command.
curl -X GET "http://hostname:port/maximo/oslc/os/mxasset?lean=1&_format=xml&oslc.where=assetnum%3D13150&oslc.select=assetnum%2Cdescription" -H "accept: application/json" -H "maxauth:bWF4YWRtaW46bWF4YWRtaW4="
3) The following response is returned in the xml format as specified in the previous step. This behavior is working as expected.
<?xml version="1.0" encoding="UTF-8"?><PublishMXASSET xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDateTime="2023-12-05T22:42:07-08:00" transLanguage="JA" baseLanguage="JA" messageID="4112217018449278721136" maximoVersion="7 6 20230224-1444 V7613-344" event="0"><MXASSETSet><ASSET><ASSETNUM>13150</ASSETNUM><DESCRIPTION>Upper Breaker System</DESCRIPTION></ASSET></MXASSETSet></PublishMXASSET>
4) From the command prompt, run the following command with the assetnum 13150A, which does not exist in the system.
curl -X GET "http://hostname:port/maximo/oslc/os/mxasset?lean=1&_format=xml&oslc.where=assetnum%3D13150A&oslc.select=assetnum%2Cdescription" -H "accept: application/json" -H "maxauth:bWF4YWRtaW46bWF4YWRtaW4="
5) The following response is returned. However, the response is not in the xml format even though "_format=xml" is specified in the previous step.
{"Error":{"extendedError":{"moreInfo":{"href":"http:\/\/:\/maximo\/oslc\/error\/messages\/BMXAA8744E"}},"reasonCode":"BMXAA8744E","message":"BMXAA8744E - OSLC \u30af\u30a8\u30ea\u30fc\u304c\u69cb\u6587\u89e3\u6790\u3055\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002HTTP \u8981\u6c42\u306e\u30af\u30a8\u30ea\u30fc\u304c\u3001OSLC \u30af\u30a8\u30ea\u30fc\u4ed5\u69d8\u306e\u6b63\u3057\u3044\u69cb\u6587\u306b\u5f93\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\tEncountered \" \"13150A \"\" at line 1, column 10.\r\nWas expecting:\r\n  ...\r\n  ","statusCode":"400"}}
6) From the command prompt, run the following command with the object structure MXASSETA, which does not exist in the system.
curl -X GET "http://hostname:port/maximo/oslc/os/mxasseta?lean=1&_format=xml&oslc.where=assetnum%3D13150&oslc.select=assetnum%2Cdescription" -H "accept: application/json" -H "maxauth:bWF4YWRtaW46bWF4YWRtaW4="
7) The following response is returned. However, the response is not in the xml format even though "_format=xml" is specified in the previous step.
{"Error":{"extendedError":{"moreInfo":{"href":"http:\/\/:\/maximo\/oslc\/error\/messages\/BMXAA4216E"}},"reasonCode":"BMXAA4216E","message":"BMXAA4216E - MXASSETA \u3068\u3044\u3046\u540d\u524d\u306e\u4e0d\u660e\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u691c\u51fa\u3055\u308c\u307e\u3057\u305f\u3002 \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30fc\u304b\u3089\u30ed\u30b0\u3092\u53ce\u96c6\u3057\u3066\u3001\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u3092\u5224\u5225\u3057\u3066\u304f\u3060\u3055\u3044\u3002","statusCode":"404"}}

Resolving The Problem

This behavior is expected as the REST API works only in json. "_format=xml" is a feature, which works when there is no error. When there is an error, it falls back to json.

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB59","label":"Sustainability Software"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSLKT6","label":"IBM Maximo Asset Management"},"ARM Category":[{"code":"a8m0z000000GpMWAA0","label":"Integration-\u003ERest API"}],"ARM Case Number":"TS014842411","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.6.1"}]

Document Information

Modified date:
07 December 2023

UID

ibm17091742