Try this:
jansson_set("string","from" , $hdr(From) , "$var(post)");
jansson_set("string","to" , $hdr(To) , "$var(post)");
jansson_set("string","call-id" , $ci , "$var(post)");
$http_req(all) = $null;
$http_req(suspend) = 0
$http_req(method) = "POST";
$http_req(hdr) = "Content-Type: application/json";
$http_req(suspend) = 0;
$http_req(body) = $var(post);
http_async_query(
"http://IP:PORT/someurl", # Endpoint
"RELAY_API_RESPONSE" # Callback route
);
Atenciosamente / Kind Regards / Cordialement / Un saludo,
*Sérgio Charrua*
On Thu, Sep 25, 2025 at 10:16 PM David Villasmil via sr-users <
[email protected]> wrote:
> 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]
>
> __________________________________________________________
> 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!
>
__________________________________________________________
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!