cancel
Showing results for 
Search instead for 
Did you mean: 

Access to HTTP status code from .Q.hmb call

trosales
New Contributor II

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

Thanks

1 ACCEPTED SOLUTION

jmcmurray
New Contributor
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 OK\r\ndate: Fri, 05 Aug 2022 13:14:33 GMT\r\ncontent-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 "\r\n" vs r[0]
"HTTP/1.1 200 OK"

View solution in original post

2 REPLIES 2

jmcmurray
New Contributor
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 OK\r\ndate: Fri, 05 Aug 2022 13:14:33 GMT\r\ncontent-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 "\r\n" vs r[0]
"HTTP/1.1 200 OK"

trosales
New Contributor II

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.