I'm assuming that you're sending to an https server and thus can't capture the
traffic on the wire, however I'd recommend testing to some other web service
running without encryption so you can check the packet capture. Similar
working code for me:
## Create JSON body for POST message:
$avp(txn_id) = $uuid(g);
jansson_set("string", "called_party", $tU, "$avp(cnam_q)");
jansson_set("string", "calling_party", $fU, "$avp(cnam_q)");
jansson_set("string", "txn_id", "$avp(txn_id)", "$avp(cnam_q)");
xinfo("CNAM Query Data: '$avp(cnam_q)'\n");
## Set the URL for the message
route(CNAM_URL);
$http_req(body) = $avp(cnam_q);
$http_req(hdr) = "Content-Type: application/json";
prom_counter_inc("http_req", "1");
http_async_query( $vn(cnam_url), "CNAM_RESPONSE" );
Regards,
Kaufman
Kaufman
Senior Voice Engineer
E: [email protected]
24/7 support: 888.543.2000
[img]
SIP.US<https://sip.us> Client Support:
800.566.9810
SIPTRUNK<https://siptrunk.com> Client Support:
800.250.6510
Flowroute<https://flowroute.com> Client Support:
855.356.9768
________________________________
From: David Villasmil via sr-users <[email protected]>
Sent: Thursday, September 25, 2025 4:02 PM
To: Kamailio (SER) - Users Mailing List <[email protected]>
Cc: David Villasmil <[email protected]>
Subject: [SR-Users] http_async_client
CAUTION: This email originated from outside the organization. Do not click
links or open attachments unless you recognize the sender and know the content
is safe.
Hello guys,
I'm trying to use http_async_client to send a json to a server and it's
supposed to use $http_req(body) to set the content... there's no way i can make
it work:
/usr/sbin/kamailio[3197588]: INFO: <script>: HTTP body:
{"from":"XXXX","to":["XXXX"],"call_id":"fJYJFHAgao","timestamp":"2025-09-25T20:14:52Z"}
<- my var
/usr/sbin/kamailio[3197588]: INFO: <script>: HTTP body: <null> <- $http_req
cfg:
xlog("L_INFO", "HTTP body: $var(body)\n");
$http_req(body) = $var(body);
xlog("L_INFO", "HTTP body: $http_req(body)\n");
It seems to me that $http_req(body) is write only, BUT on the web server:
{"error":"Invalid request: missing required fields (from, to)","received":{}}
[353]
Help is appreciated, thanks!
Regards,
David Villasmil
email: [email protected]<mailto:[email protected]>
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions --
[email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the
sender!