[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wsf-javascript-dev
Subject:    Re: [Dev] [Issue] Jaggery post() method
From:       Tishan Dahanayakage <tishan () wso2 ! com>
Date:       2014-08-29 12:23:11
Message-ID: CAJkAgEFkP8yzn+JNQWTLZgeuGaVz0dZ6x+2ccRuta64BfkzVvQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Jerad,
Does your end point URL has a service to serve your HTTP post? Since
Jaggery post is a wrapper for XMLHTTPRequest post as per jaggery
documentation, make sure your URL (http://localhost:8280/) can handle your
post and return a response.
And I think your JSON data does not need apostrophe at beginning and end.
Also please note that in this particular request you are setting HTTP
headers. (var res = post(url,[ data],[ headers],[ type]))
For the issue of documentation try out not working please raise a JIRA at
[1].

[1] https://wso2.org/jira/browse/JAGGERY


On Thu, Aug 28, 2014 at 5:19 PM, Jerad Rutnam <jerad@wso2.com> wrote:

> Hi Milinda,
>
> Thanks for the reply. Yes, I too noticed that. I think we better get this
> fix right? I'm not sure whom to inform. :)
> Anyway my actual requirement is to post() a json string with an array to
> esb and get the response. Here is the code I used. But it throws an
> exception. Any idea where I did wrong? Help will be appreciate.
>
> <%
>
>   var url = 'http://localhost:8280/';
>   var result = post(url, 'Jaggery HTTP POST', {'"newbies" :
> [{"name":"Dinesh"}, {"name":"Dilan"}, {"name":"Jerad"}]'},
> 'application/json');
>   print(result.data);
>
> %>
>
>
> Thanks,
> Jerad
>
>
> On Thu, Aug 28, 2014 at 4:12 PM, Milinda Perera <milindap@wso2.com> wrote:
>
>> Hi,
>>
>> Seems 'http://jaggeryjs.org/apidocs/resources/data.jag' resource is not
>> available.
>>
>> Thanks,
>> Milinda
>>
>>
>>
>>
>> On Thu, Aug 28, 2014 at 3:39 PM, Jerad Rutnam <jerad@wso2.com> wrote:
>>
>>> Hi,
>>>
>>> Tried to use Jaggery post() method. And it's not working as expected.
>>> getting an error on the documentation try out feature.
>>>
>>>
>>> *Sample*
>>> <%
>>> var url = 'http://jaggeryjs.org/apidocs/resources/data.jag';
>>> var result = post(url, 'Jaggery HTTP POST', {
>>>     "User-Agent" : "Jaggery-XHR",
>>>     "Country" : "LK"
>>> }, 'json');
>>> print(result.data);
>>> %>
>>>
>>> *On the local jaggery server*
>>> *com.google.gson.JsonSyntaxException:
>>> com.google.gson.stream.MalformedJsonException: Expected EOF at line 1
>>> column 27 at line #3*
>>>
>>> * On the "jaggeryjs.org <http://jaggeryjs.org>" **website*
>>> *org.jaggeryjs.scriptengine.exceptions.ScriptException:
>>> java.net.ConnectException: Connection timed out at line #3*
>>>
>>> *http://jaggeryjs.org/documentation.jag?api=post
>>> <http://jaggeryjs.org/documentation.jag?api=post>*
>>>
>>>
>>> Any feedback appreciate
>>>
>>> *Regards,*
>>>
>>> *Jerad*
>>>
>>> --
>>> *Jerad Rutnam | **Software Engineer - UI*
>>> WSO2, Inc. www.wso2.com
>>>
>>> *Email: jerad@wso2.com <jerad@wso2.com>*
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Milinda Perera
>> Software Engineer;
>> WSO2 Inc. http://wso2.com ,
>> Mobile: (+94) 714 115 032
>>
>>
>
>
> --
> *Jerad Rutnam | **Software Engineer - UI*
> WSO2, Inc. www.wso2.com
>
> *Email: jerad@wso2.com <jerad@wso2.com>*
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Tishan Dahanayakage
Software Engineer
WSO2, Inc.
Mobile:+94 716481328

Disclaimer: This communication may contain privileged or other confidential
information and is intended exclusively for the addressee/s. If you are not
the intended recipient/s, or believe that you may have received this
communication in error, please reply to the sender indicating that fact and
delete the copy you received and in addition, you should not print, copy,
re-transmit, disseminate, or otherwise use the information contained in
this communication. Internet communications cannot be guaranteed to be
timely, secure, error or virus-free. The sender does not accept liability
for any errors or omissions.

[Attachment #5 (text/html)]

<div dir="ltr">Hi Jerad,<br>Does your end point URL has a service to serve your HTTP \
post? Since Jaggery post is a wrapper for  XMLHTTPRequest post as per jaggery \
documentation, make sure your URL (<a href="http://localhost:8280/" \
target="_blank">http://localhost:8280/</a>) can handle your post and return a \
response.  <div> And I think your JSON data does not need apostrophe at beginning and \
end. Also please note that in this particular request you are setting HTTP headers. \
(var res = post(url,[ data],[ headers],[ type]))<br>For the issue of documentation \
try out not working please raise a JIRA at [1].<div> <br></div><div>[1]  <a \
href="https://wso2.org/jira/browse/JAGGERY">https://wso2.org/jira/browse/JAGGERY</a></div></div></div><div \
class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 28, 2014 at 5:19 PM, \
Jerad Rutnam <span dir="ltr">&lt;<a href="mailto:jerad@wso2.com" \
target="_blank">jerad@wso2.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">Hi Milinda,<div><br>Thanks for the reply. Yes, \
I too noticed that. I think we better get this fix right? I&#39;m not sure whom to \
inform. :)<br> Anyway my actual requirement is to post() a json string with an array \
to esb and get the response. Here is the code I used. But it throws an exception. Any \
idea where I did wrong? Help will be appreciate.<br> \
<br><div>&lt;%</div><div><br></div><div><span style="white-space:pre-wrap">      \
</span>var url = &#39;<a href="http://localhost:8280/" \
target="_blank">http://localhost:8280/</a>&#39;;</div><div><span \
style="white-space:pre-wrap">      </span>var result = post(url, &#39;Jaggery HTTP \
POST&#39;, {&#39;&quot;newbies&quot; : [{&quot;name&quot;:&quot;Dinesh&quot;}, \
{&quot;name&quot;:&quot;Dilan&quot;}, {&quot;name&quot;:&quot;Jerad&quot;}]&#39;}, \
&#39;application/json&#39;);</div>

<div><span style="white-space:pre-wrap">      \
</span>print(result.data);</div><div><br></div><div>%&gt;</div><br><br>Thanks,<br>Jerad</div></div><div \
class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div \
class="gmail_quote"> On Thu, Aug 28, 2014 at 4:12 PM, Milinda Perera <span \
dir="ltr">&lt;<a href="mailto:milindap@wso2.com" \
target="_blank">milindap@wso2.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi,<br><br></div>Seems &#39;<a \
href="http://jaggeryjs.org/apidocs/resources/data.jag" \
target="_blank">http://jaggeryjs.org/apidocs/resources/data.jag</a>&#39; resource is \
not available.<br>

<br>
</div>Thanks,<br></div>Milinda<br><br><br></div><div class="gmail_extra"><br><br><div \
class="gmail_quote"><div><div>On Thu, Aug 28, 2014 at 3:39 PM, Jerad Rutnam <span \
dir="ltr">&lt;<a href="mailto:jerad@wso2.com" \
target="_blank">jerad@wso2.com</a>&gt;</span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi,<div><br></div><div>Tried to \
use Jaggery post() method. And it&#39;s not working as expected. getting an error on \
the documentation try out feature.<br>


<br><br><i><b>Sample</b></i></div><div><div>&lt;%</div>
<div>var url = &#39;<a href="http://jaggeryjs.org/apidocs/resources/data.jag" \
target="_blank">http://jaggeryjs.org/apidocs/resources/data.jag</a>&#39;;</div><div>var \
result = post(url, &#39;Jaggery HTTP POST&#39;, {</div>


<div>      &quot;User-Agent&quot; : &quot;Jaggery-XHR&quot;,</div>
<div>      &quot;Country&quot; : &quot;LK&quot;</div><div>}, \
&#39;json&#39;);</div><div>print(result.data);</div><div>%&gt;</div><div><br></div><font \
color="#000000"><b><i><font face="arial, helvetica, sans-serif">On the local jaggery \
server</font></i></b></font><br>



<span style="color:rgb(0,0,0)"><font face="garamond, \
serif"><i>com.google.gson.JsonSyntaxException: \
com.google.gson.stream.MalformedJsonException: Expected EOF at line 1 column 27 at \
line #3</i></font></span></div><div><font color="#000000"><b><i><br>



<font face="arial, helvetica, sans-serif">On the &quot;<a href="http://jaggeryjs.org" \
target="_blank">jaggeryjs.org</a>&quot;  </font></i></b></font><b \
style="color:rgb(0,0,0)"><i><font face="arial, helvetica, \
sans-serif">website</font></i></b></div>



<div><span style="color:rgb(0,0,0);font-family:&#39;Times New \
Roman&#39;"><i>org.jaggeryjs.scriptengine.exceptions.ScriptException: \
java.net.ConnectException: Connection timed out at line #3</i></span><font \
color="#000000" face="garamond, serif" size="3"><b><i><br>



</i></b></font><br><i><a href="http://jaggeryjs.org/documentation.jag?api=post" \
target="_blank">http://jaggeryjs.org/documentation.jag?api=post</a></i></div><div><br></div><div><i><br></i></div><div>Any \
feedback appreciate</div>


<div><i><br>
</i></div><div><i>Regards,</i></div><div><i>Jerad<span><font color="#888888"><br \
clear="all"></font></span></i><span><font color="#888888"><div><br></div>-- <br><div \
dir="ltr"><b>Jerad Rutnam |  </b><i>Software Engineer - UI</i><div>


WSO2, Inc. <a href="http://www.wso2.com" target="_blank">www.wso2.com</a></div>
<div><br></div><div><i>Email: <u><a href="mailto:jerad@wso2.com" \
target="_blank">jerad@wso2.com</a></u></i></div></div> </font></span></div></div>
<br></div></div>_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@wso2.org" target="_blank">Dev@wso2.org</a><br>
<a href="http://wso2.org/cgi-bin/mailman/listinfo/dev" \
target="_blank">http://wso2.org/cgi-bin/mailman/listinfo/dev</a><br> \
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><br>-- \
<br><div dir="ltr"><div><span><font color="#888888"><span><font>Milinda \
Perera<br>Software Engineer; <br>WSO2 Inc. <a href="http://wso2.com" \
target="_blank">http://wso2.com</a> ,<br>


</font></span></font></span></div><span><font color="#888888"><span><font>Mobile: <a \
href="tel:%28%2B94%29%20714%20115%20032" value="+94714115032" target="_blank">(+94) \
714 115 032</a><br><br></font></span></font></span></div>


</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><b>Jerad \
Rutnam |  </b><i>Software Engineer - UI</i><div>WSO2, Inc. <a \
href="http://www.wso2.com" target="_blank">www.wso2.com</a></div><div><br>

</div><div><i>Email: <u><a href="mailto:jerad@wso2.com" \
target="_blank">jerad@wso2.com</a></u></i></div></div> </div>
</div></div><br>_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@wso2.org">Dev@wso2.org</a><br>
<a href="http://wso2.org/cgi-bin/mailman/listinfo/dev" \
target="_blank">http://wso2.org/cgi-bin/mailman/listinfo/dev</a><br> \
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div \
dir="ltr"><div><font face="tahoma, sans-serif">Tishan \
Dahanayakage</font></div><div><font face="tahoma, sans-serif">Software \
Engineer</font></div><div> <font face="tahoma, sans-serif">WSO2, \
Inc.</font></div><div><font face="tahoma, sans-serif">Mobile:+94 \
716481328</font></div><div><font face="tahoma, \
sans-serif"><br></font></div><div><font face="tahoma, sans-serif">Disclaimer: This \
communication may contain privileged or other confidential information and is \
intended exclusively for the addressee/s. If you are not the intended recipient/s, or \
believe that you may have received this communication in error, please reply to the \
sender indicating that fact and delete the copy you received and in addition, you \
should not print, copy, re-transmit, disseminate, or otherwise use the information \
contained in this communication. Internet communications cannot be guaranteed to be \
timely, secure, error or virus-free. The sender does not accept liability for any \
errors or omissions.  </font></div> </div>
</div>



_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic