Troubleshooting REST service requests
If Db2 cannot successfully execute an HTTP service request, an HTTP status code is provided in the response header and body that indicates the general category for the failure. The response body also includes a StatusDescription field that might provide additional information about the reason for the failure.
The following table describes the HTTP status codes for common error conditions.
| HTTP status code | Description |
|---|---|
| HTTP 500 (Internal Server Error) | Indicates that the server could not fulfill a request. In most cases, the HTTP code is accompanied by a Db2 SQL code that provides more details about the error condition. |
| HTTP 400 (Bad Request) | Indicates a problem with an input parameter, such as a missing required input parameter, that is detected by the Db2 DDF native REST code before executing the Db2 SQL statement. This code is also used for many DB2ServiceManager failures (for example, Create/Drop service) and DB2DiscoverService failures (discover service/discover service details), which are typically caused by incorrect or missing inputs. |
| HTTP 401 (Unauthorized) | Indicates that the user could not be successfully authenticated. |
| HTTP 403 (Forbidden) | Indicates that the user might not have the required permissions to access a resource. |
The following example shows a request in which the input for the "HIREDATE" parameter value, which targets a Db2 DATE column, fails because the input was not provided in a valid DATE format:
POST http://hostname.ibm.com:446/services/SYSIBMSERVICE/inDateConvertError
Request body:
{
"HIREDATE":"NOT_A_DATE"
}The response to this request includes an HTTP status code followed by the StatusDescription section, which provides details about the error condition. In this case, a Db2 SQL code is also included.HTTP reply msg Header Fields:{null=[HTTP/1.1 500 Internal Server Error], Content-Language=[en-US],
Date=[Fri, 31 Mar 2017 18:23:28 GMT], Content-Length=[229], Content-Type=[application/json; charset=UTF-8],
X-Powered-By=[DB2 for z/OS], Server=[DB2 DDF Native REST, STLEC1]}
Response body:
{
"StatusCode":500,
"StatusDescription":"Service SYSIBMSERVICE.inDateConvertError execution failed due to SQL error,
SQLCODE=-180, SQLSTATE=22007, Message=THE DATE, TIME, OR TIMESTAMP VALUE *N IS INVALID Error Location:DSNLJXUS:6"
}