KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Access to HTTP status code from .Q.hmb call

  • Access to HTTP status code from .Q.hmb call

    Posted by trosales on August 5, 2022 at 12:00 am

    Is there a way to access the HTTP status code (ex: HTTP/1.1 200 OK) after a call to .Q.hmb?

    Thanks

    trosales replied 9 months, 2 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • jmcmurray

    Member
    August 8, 2022 at 12:00 am
    With .Q.hmb, return is two strings, first one is HTTP response headers:
    q).Q.hmb["https://httpbin.org/get";`GET;()] "HTTP/1.1 200 OKrndate: Fri, 05 Aug 2022 13:14:33 GMTrncontent-type: appl.. "{n  "args": {}, n  "headers": {n    "Accept-Encoding": "gzip", n..
    So it’s simple enough to extract the status:
    q)r:.Q.hmb["https://httpbin.org/get";`GET;()] q)first "rn" vs r[0] "HTTP/1.1 200 OK"
  • trosales

    Member
    August 8, 2022 at 12:00 am

    I was using q v3.4 and getting only 1 string back from .Q.hmb.  When I used q v4.0, I got the 2 string response you mentioned.  Thank you for the help.

Log in to reply.