Status codes
Each API request that is sent to the server returns a response that includes an HTTP status code and any requested information.
The following are some of the common HTTP status codes:
- 200 OK
- The endpoint operation was successful.
- 201 Created
- The endpoint operation was successful and resulted in the creation of a resource.
- 202 Accepted
- The request is accepted for processing, but the processing is not yet completed. Asynchronous endpoints return this status code in the response to the original request.
- 204 No content
- The endpoint operation was successful, but no content is returned in the response.
- 303 [interim response status]
- The endpoint operation is in progress. Asynchronous endpoints return this status code in response to a request for status.
- 400 Bad Request
- 403 Forbidden
- 404 Not Found
- 500 Internal Server Error
Along with the HTTP status codes, the Db2® Warehouse API
service also returns an error reason in the
reason
field of a JSON dictionary. In
the following example, a request to add a record to a database is rejected with the status error
code 400 "BAD REQUEST". The reason code
contains more information, including the following error message:
curl -k -v -H 'Authorization: Bearer <token>'
https://<spectrum_discover_host>/db2whrest/v1/sql_query -X POST -d"select *
from labsrv04 where ownerzzz='root'"
<HTTP/1.1 400 BAD REQUEST
{"reason": "('42S22', '[42S22] [IBM][CLI Driver][DB2/LINUXX8664] SQL0206N \"OWNERZZZ\" is not
valid in the context where it is used. SQLSTATE=42703\\n')", "status": "error"}