ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Getting HTTP Status Code after running HTTP_xxxx function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting HTTP Status Code after running HTTP_xxxx function

    After executing an embedded SQL HTTP_xxxx or HTTP_xxxx_VERBOSE function, is there no way to get the HTTP status code?
    I mean without searching the response header, when I don't necessarily know what the key name for the status value is?

  • #2
    No, I don't think there is any other way. However I would expect the key names of the standard response headers, such as HTTP status code, to always be the same: "HTTP_STATUS_CODE"

    Here's an example using HTTP_POST_VERBOSE, with JSON_TABLE to decode the HTTP status from the response header:
    Code:
    SELECT * FROM TABLE(QSYS2.HTTP_POST_VERBOSE(
                       'http://myIbmiServer/fakepath',
                       'ABC')) h,
    JSON_TABLE(h.RESPONSE_HTTP_HEADER, 'lax $' columns (
      httpStatusCode varchar(5) path 'lax $.HTTP_STATUS_CODE'
    )) as j​

    Comment

    Working...
    X