[SR-Users] HTTP Post with JSON

eyas barhouk eyas37 at hotmail.com
Wed Oct 17 22:24:42 CEST 2018


many thanks Dear Alex

i will make some tests and try it as u mentioned .

________________________________
From: sr-users <sr-users-bounces at lists.kamailio.org> on behalf of Alex Balashov <abalashov at evaristesys.com>
Sent: Wednesday, October 17, 2018 8:18 PM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] HTTP Post with JSON

On Wed, Oct 17, 2018 at 08:01:59PM +0000, eyas barhouk wrote:

> thanks dear Alex
>
>
> i tried this function "http_client_query(url, [post-data], [hdrs],
> result)" but there is no example about how to use more than one header
> .
>
>
> if you can send me an example about how to setup the query with two
> headers like "content type" & "Authentication "

You're right, there is no example, and that's unfortunate.

I just tinkered with it, and it looks like an ordinary newline
delimiter works, but omit the last one:

In other words:

Bad --

        http_client_query("http://www.evaristesys.com/",
Introduction | Evariste Systems<http://www.evaristesys.com/>
www.evaristesys.com
Evariste Systems is a software company specialising in open source-focused VoIP service delivery engineering for Internet Telephony Service Providers (ITSPs) and carriers.



                "a=1&b=2",
                "Content-Type: application/json\n"
                "Authentication: Basic Z29hdDpjaGVlc2U6cmVhbG0K==\n",
                "$var(result)");

        POST / HTTP/1.1
        User-Agent: kamailio (5.2.0-pre0 (x86_64/linux))
        Host: www.evaristesys.com<http://www.evaristesys.com>
        Accept: */*
        Content-Type: application/json
        Authentication: Basic Z29hdDpjaGVlc2U6cmVhbG0K==

        Content-Length: 7

        a=1&b=2

Good --

        http_client_query("http://www.evaristesys.com/",
                 "a=1&b=2",
                "Content-Type: application/json\n"
                "Authentication: Basic Z29hdDpjaGVlc2U6cmVhbG0K==",
                "$var(result)");


        POST / HTTP/1.1
        User-Agent: kamailio (5.2.0-pre0 (x86_64/linux))
        Host: www.evaristesys.com<http://www.evaristesys.com>
        Accept: */*
        Content-Type: application/json
        Authentication: Basic Z29hdDpjaGVlc2U6cmVhbG0K==
        Content-Length: 7

        a=1&b=2

-- Alex

--
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users at lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20181017/877812a3/attachment.html>


More information about the sr-users mailing list