Hello Dears
i'm trying to send POST HTTP request with JSON content on Kamailio V 5.2.0. i have two main headers "content type" & "Authentication " in addition i have the json content . when i'm using curl request it look like :
Curl -H "Authentication ket = xxxxx" -H "content type : JSON" -d " {the JSON content}" https://xxxxx.com/send
So how can i use the Http_client module to send such requests ??
thanks in advance .
On Wed, Oct 17, 2018 at 07:53:21PM +0000, eyas barhouk wrote:
The answer smiles out at you in the documentation:
https://kamailio.org/docs/modules/5.1.x/modules/http_client.html#http_client...
-- Alex
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 "
i will be thankful .
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Alex Balashov abalashov@evaristesys.com Sent: Wednesday, October 17, 2018 7:56 PM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] HTTP Post with JSON
On Wed, Oct 17, 2018 at 07:53:21PM +0000, eyas barhouk wrote:
The answer smiles out at you in the documentation:
https://kamailio.org/docs/modules/5.1.x/modules/http_client.html#http_client...
-- 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@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
On Wed, Oct 17, 2018 at 08:01:59PM +0000, eyas barhouk wrote:
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/", "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 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 Accept: */* Content-Type: application/json Authentication: Basic Z29hdDpjaGVlc2U6cmVhbG0K== Content-Length: 7
a=1&b=2
-- Alex
many thanks Dear Alex
i will make some tests and try it as u mentioned .
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Alex Balashov abalashov@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:
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 Systemshttp://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.comhttp://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.comhttp://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@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
dears thanks for your feedback.
but after many tests i found that http_client module can't handle more than one header :\
i solve this issue by using EXEC module as in the following :
exec_msg("curl -X POST -H "Authorization: $var(key)" -H "Content-Type: application/json" -d '{"notification":{"body": "TEST","title":"Hello"},"to":"user"}' \ "https://tests.com/send/"
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Olle E. Johansson oej@edvina.net Sent: Thursday, October 18, 2018 6:52 AM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] HTTP Post with JSON
So much for answering before reading the full thread. Thanks Alex!
/O :-)
[http://www.evaristesys.com/images/athens_ga_panorama.jpg]http://www.evaristesys.com/
Introduction | Evariste Systemshttp://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.
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
It worked in my test.
Using the exec module is a terrible idea from a performance point of view.
-- Sent from mobile. Apologies for brevity and errors.
-----Original Message----- From: eyas barhouk eyas37@hotmail.com To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Sent: Thu, 18 Oct 2018 7:45 AM Subject: Re: [SR-Users] HTTP Post with JSON
dears thanks for your feedback.
but after many tests i found that http_client module can't handle more than one header :\
i solve this issue by using EXEC module as in the following :
exec_msg("curl -X POST -H "Authorization: $var(key)" -H "Content-Type: application/json" -d '{"notification":{"body": "TEST","title":"Hello"},"to":"user"}' \ "https://tests.com/send/"
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Olle E. Johansson oej@edvina.net Sent: Thursday, October 18, 2018 6:52 AM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] HTTP Post with JSON
So much for answering before reading the full thread. Thanks Alex!
/O :-)
[http://www.evaristesys.com/images/athens_ga_panorama.jpg]http://www.evaristesys.com/
Introduction | Evariste Systemshttp://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.
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
I tried again and it succesed with http_client , sorry it was my false dear Alex..
Get Outlook for Androidhttps://aka.ms/ghei36
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Alex Balashov abalashov@evaristesys.com Sent: Thursday, October 18, 2018 2:47:03 PM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] HTTP Post with JSON
It worked in my test.
Using the exec module is a terrible idea from a performance point of view.
-- Sent from mobile. Apologies for brevity and errors.
-----Original Message----- From: eyas barhouk eyas37@hotmail.com To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Sent: Thu, 18 Oct 2018 7:45 AM Subject: Re: [SR-Users] HTTP Post with JSON
dears thanks for your feedback.
but after many tests i found that http_client module can't handle more than one header :\
i solve this issue by using EXEC module as in the following :
exec_msg("curl -X POST -H "Authorization: $var(key)" -H "Content-Type: application/json" -d '{"notification":{"body": "TEST","title":"Hello"},"to":"user"}' \ "https://tests.com/send/"
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Olle E. Johansson oej@edvina.net Sent: Thursday, October 18, 2018 6:52 AM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] HTTP Post with JSON
So much for answering before reading the full thread. Thanks Alex!
/O :-)
[http://www.evaristesys.com/images/athens_ga_panorama.jpg]http://www.evaristesys.com/
Introduction | Evariste Systemshttp://www.evaristesys.com/ www.evaristesys.comhttp://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.
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
I am gratified that it successed.
-- Sent from mobile. Apologies for brevity and errors.
-----Original Message----- From: eyas barhouk eyas37@hotmail.com To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Sent: Thu, 18 Oct 2018 8:31 AM Subject: Re: [SR-Users] HTTP Post with JSON
I tried again and it succesed with http_client , sorry it was my false dear Alex..
Get Outlook for Androidhttps://aka.ms/ghei36
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Alex Balashov abalashov@evaristesys.com Sent: Thursday, October 18, 2018 2:47:03 PM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] HTTP Post with JSON
It worked in my test.
Using the exec module is a terrible idea from a performance point of view.
-- Sent from mobile. Apologies for brevity and errors.
-----Original Message----- From: eyas barhouk eyas37@hotmail.com To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Sent: Thu, 18 Oct 2018 7:45 AM Subject: Re: [SR-Users] HTTP Post with JSON
dears thanks for your feedback.
but after many tests i found that http_client module can't handle more than one header :\
i solve this issue by using EXEC module as in the following :
exec_msg("curl -X POST -H "Authorization: $var(key)" -H "Content-Type: application/json" -d '{"notification":{"body": "TEST","title":"Hello"},"to":"user"}' \ "https://tests.com/send/"
________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Olle E. Johansson oej@edvina.net Sent: Thursday, October 18, 2018 6:52 AM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] HTTP Post with JSON
So much for answering before reading the full thread. Thanks Alex!
/O :-)
[http://www.evaristesys.com/images/athens_ga_panorama.jpg]http://www.evaristesys.com/
Introduction | Evariste Systemshttp://www.evaristesys.com/ www.evaristesys.comhttp://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.
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users