Home › Forums › kdb+ › Why a curl command works but a similar .Q.hp command fails when sending alerts to TEAMS from KDB › Re: Why a curl command works but a similar .Q.hp command fails when sending alerts to TEAMS from KDB
-
You can use a second q process help you to debug.
Set a Listening-port p and have the HTTP Post handler (.z.pp) print incoming message contents
p 5000 .z.pp:{show x;x}
Trying curl from command line
$ curl -H ‘Content-type: application/json’ -d ‘{“text”:”Hello World”}’ localhost:5000
The server q process prints:
” {“text”:”Hello World”}” `Host`User-Agent`Accept`Content-type`Content-Length!(“localhost:5000″;”curl/7.58.0″;”*/*”;”application/json”;”22″)
From a client q process using .Q.hp
q).Q.hp[“http://localhost:5000″;.h.ty`json] .j.j enlist[`text]!enlist”Hello World”
The server q process prints:
” {“text”:”Hello World”}” `Accept-Encoding`Connection`Host`Content-type`Content-length!(“gzip”;”close”;”localhost:5000″;”application/json”;”22″)
There are only slight differences in the headers.
You may need to consult documentation of the server you are connecting to to confirm if it has specific header requirements.
(Clients using KX Insights have access to kurl with more options than .Q.hp)