<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>Hey Colin,</div>
<div><br>
</div>
<div>Perfect will try it out.</div>
<div><br>
</div>
<div>Thanks very much.</div>
<div><br>
</div>
<div>Jon </div>
<div><br>
<br>
<div class="acompli_signature">Get <a href="https://aka.ms/o0ukef">Outlook for iOS</a></div>
<br>
</div>
<br>
<br>
<br>
<div class="gmail_quote">On Mon, Aug 22, 2016 at 2:57 PM +0100, "Colin Morelli" <span dir="ltr">
<<a href="mailto:colin.morelli@gmail.com" target="_blank">colin.morelli@gmail.com</a>></span> wrote:<br>
<br>
</div>
<div>
<div dir="ltr">Hey Jonathan,
<div><br>
</div>
<div>You can also use the Jansson module to create the JSON request. For example, in one of my configs, I have a route that looks basically like:</div>
<div><br>
</div>
<div>
<div><font face="monospace">$var(params) = $null;</font></div>
<div><font face="monospace">jansson_set("string", "request.uri", "$ru", "$var(params)");</font></div>
<div><font face="monospace">jansson_set("string", "request.method", "$rm", "$var(params)");</font></div>
<div><font face="monospace">jansson_set("string", "request.domain", "$rd", "$var(params)");</font></div>
</div>
<div><font face="monospace">/// other fields set here</font></div>
<div>
<div><font face="monospace">http_set_timeout(5000);</font></div>
<div><font face="monospace">http_set_method("POST");</font></div>
<div><font face="monospace">http_append_header("Content-Type: application/json");</font></div>
<div><font face="monospace">http_async_query("<a href="https://mydomain.com/api/v1/blah">https://mydomain.com/api/v1/blah</a>", "$var(params)", "API_ROUTE_REPLY");</font></div>
</div>
<div><font face="monospace"><br>
</font></div>
<div>Then a API_ROUTE_REPLY block that processes the response like:<font face="monospace"><br>
</font></div>
<div><br>
</div>
<div>
<div><font face="monospace">if $http_ok {</font></div>
<div><font face="monospace">    if $http_rs == 200 {</font></div>
<div><font face="monospace">      $var(action) = $null;</font></div>
<div><font face="monospace">      jansson_get_field("$http_rb", "authentication.action", "$var(action)");</font></div>
</div>
<div><font face="monospace">      // other stuff</font></div>
<div><font face="monospace">   }</font></div>
<div><font face="monospace">}</font></div>
<div><font face="monospace"><br>
</font></div>
<div>Hopefully that's helpful.<br>
</div>
<div><br>
</div>
<div>Best,</div>
<div>Colin</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr">On Mon, Aug 22, 2016 at 9:52 AM Jonathan Hunter <<a href="mailto:hunterj91@hotmail.com">hunterj91@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div dir="ltr">
<div>Hi Guys,</div>
<div><br>
</div>
<div>I need to send a JSON document over HTTP to a server, and then process the response, both in the kamailio configuration file.</div>
<div><br>
</div>
<div>I assume I need to use Jansson module to extract contents of response?</div>
<div><br>
</div>
<div>What is the best method for generating the initial request containing JSON ?</div>
<div><br>
</div>
<div><br>
</div>
<div>Many thanks</div>
<div><br>
</div>
<div>Jon</div>
</div>
</div>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote>
</div>
</div>
</body>
</html>