Hi folks,
I am using kamailio -v version: kamailio 5.0.2 (x86_64/linux) flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: unknown compiled on 10:02:27 Jul 4 2017 with gcc 4.9.2
I was trying to send http POST request to my web server example.com following example Example 1.12. http_async_query() usage https://www.kamailio.org/docs/modules/5.0.x/modules/http_async_client.html#http_async_client.f.http_async_query
https://www.kamailio.org/docs/modules/5.0.x/modules/http_async_client.html
according to that we should send parameters in body like
# POST $http_req(body) = "{'r_uri':'" + $rU + "', 'f_uri':'" + $fU + "'}"; http_async_query("http://example.com/test.php", "HTTP_REPLY");
But its not working out of the box as described with error message from server:
INFO: <script>: route[HTTP_REPLY]: status 400 INFO: <script>: route[HTTP_REPLY]: body Insufficient parameters.
I even tried adding additional parameters $http_req(hdr) = "Content-Type: application/x-www-form-urlencoded"; $http_req(method) = "POST";
But again it didn't work.
I tried the alternative way which worked fine.
# POST $http_req(body) = "r_uri=$rU&f_uri=$fU"; http_async_query("http://example.com/test.php", "HTTP_REPLY");
Is there any issue with documentation or i am missing something for POST request?
-- regards,
abdul basit | p: +92 32 1416 4196 | o: +92 30 0841 1445
Check data on wire between actual and expected ngrep or tcpdump... it looks like your response is not a kamailio reply, yet web server returns the 400 / response.
On Thu, Jul 13, 2017 at 1:40 AM Abdul Basit basit.engg@gmail.com wrote:
Hi folks,
I am using kamailio -v version: kamailio 5.0.2 (x86_64/linux) flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: unknown compiled on 10:02:27 Jul 4 2017 with gcc 4.9.2
I was trying to send http POST request to my web server example.com following example Example 1.12. http_async_query() usage https://www.kamailio.org/docs/modules/5.0.x/modules/http_async_client.html#http_async_client.f.http_async_query
https://www.kamailio.org/docs/modules/5.0.x/modules/http_async_client.html
according to that we should send parameters in body like
# POST $http_req(body) = "{'r_uri':'" + $rU + "', 'f_uri':'" + $fU + "'}"; http_async_query("http://example.com/test.php", "HTTP_REPLY");
But its not working out of the box as described with error message from server:
INFO: <script>: route[HTTP_REPLY]: status 400 INFO: <script>: route[HTTP_REPLY]: body Insufficient parameters.
I even tried adding additional parameters $http_req(hdr) = "Content-Type: application/x-www-form-urlencoded"; $http_req(method) = "POST";
But again it didn't work.
I tried the alternative way which worked fine.
# POST $http_req(body) = "r_uri=$rU&f_uri=$fU"; http_async_query("http://example.com/test.php", "HTTP_REPLY");
Is there any issue with documentation or i am missing something for POST request?
-- regards,
abdul basit | p: +92 32 1416 4196 | o: +92 30 0841 1445 _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Hi, this has nothing to do with the module. The reply is coming from your http server. In the first request you are sending a json body with "Content-Type: application/x-www-form-urlencoded" while it should be "Content-Type: application/json". In the second request you are sending a totally different body. You should check your webserver's logs.
Best regards,
Federico Cabiddu
Hi, Brandon and Federico
Thank you for your reply.
Web server is not in my access and since its https request tcpdump will not help until i get specific certificates. I replaced the URL here. Yes. 400 response is from server side.
# POST $http_req(body) = "r_uri=$rU&f_uri=$fU"; http_async_query("https://example.com/test.php", "HTTP_REPLY");
Its working fine without any header specification.
However, when i try to send in the example format:
# POST $http_req(hdr) = "Content-Type: application/json"; $http_req(method) = "POST"; $http_req(body) = "{'r_uri':'" + $rU + "', 'f_uri':'" + $fU + "'}"; http_async_query("https://example.com/test.php", "HTTP_REPLY");
It results in INFO: <script>: route[HTTP_REPLY]: status 400 INFO: <script>: route[HTTP_REPLY]: body Insufficient parameters.
where should i look?
-- regards,
abdul basit | p: +92 32 1416 4196 | o: +92 30 0841 1445
On 13 July 2017 at 13:46, Federico Cabiddu federico.cabiddu@gmail.com wrote:
Hi, this has nothing to do with the module. The reply is coming from your http server. In the first request you are sending a json body with "Content-Type: application/x-www-form-urlencoded" while it should be "Content-Type: application/json". In the second request you are sending a totally different body. You should check your webserver's logs.
Best regards,
Federico Cabiddu
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Well. I found the issue.
I coordinated with service provider. They don't support json which was the main cause. However, i suggest to extend example further with
# POST $http_req(hdr) = "Content-Type: application/x-www-form-urlencoded"; $http_req(body) = "r_uri=$rU&f_uri=$fU"; http_async_query("http://example.com/test.php", "HTTP_REPLY");
I hope this will save others time.
-- regards,
abdul basit | p: +92 32 1416 4196 | o: +92 30 0841 1445
On 13 July 2017 at 16:49, Abdul Basit basit.engg@gmail.com wrote:
Hi, Brandon and Federico
Thank you for your reply.
Web server is not in my access and since its https request tcpdump will not help until i get specific certificates. I replaced the URL here. Yes. 400 response is from server side.
# POST $http_req(body) = "r_uri=$rU&f_uri=$fU"; http_async_query("https://example.com/test.php", "HTTP_REPLY");
Its working fine without any header specification.
However, when i try to send in the example format:
# POST $http_req(hdr) = "Content-Type: application/json"; $http_req(method) = "POST"; $http_req(body) = "{'r_uri':'" + $rU + "', 'f_uri':'" + $fU + "'}"; http_async_query("https://example.com/test.php", "HTTP_REPLY");
It results in INFO: <script>: route[HTTP_REPLY]: status 400 INFO: <script>: route[HTTP_REPLY]: body Insufficient parameters.
where should i look?
-- regards,
abdul basit | p: +92 32 1416 4196 | o: +92 30 0841 1445
On 13 July 2017 at 13:46, Federico Cabiddu federico.cabiddu@gmail.com wrote:
Hi, this has nothing to do with the module. The reply is coming from your http server. In the first request you are sending a json body with "Content-Type: application/x-www-form-urlencoded" while it should be "Content-Type: application/json". In the second request you are sending a totally different body. You should check your webserver's logs.
Best regards,
Federico Cabiddu
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users