Re: [Dev] Invoking a Jaggery api via HttpURLConnection

2016-09-26 Thread Denuwanthi De Silva
Hi , The above get() method returned the response as null. After several attempts finally got it working with following approach with the help of Nipuna. Thanks a lot Nipuna for helping to sort this out. var xhr = new XMLHttpRequest(); xhr.open("GET", url); xhr.setRequestHeader("Accept" ,

Re: [Dev] Invoking a Jaggery api via HttpURLConnection

2016-09-23 Thread Denuwanthi De Silva
Hi Sameera, I could get it working with following approach[1]: var headers ={"Accept" : "application/json"}; var response = get(url,null,headers,'text'); [1] http://stackoverflow.com/questions/34505509/jaggeryjs-ajax-call-get-method Thanks On Fri, Sep 23, 2016 at 5:21 PM, Denuwanthi De

Re: [Dev] Invoking a Jaggery api via HttpURLConnection

2016-09-23 Thread Denuwanthi De Silva
Hi Sameera, Please find the stacktrace Stacktrace: at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) at

Re: [Dev] Invoking a Jaggery api via HttpURLConnection

2016-09-23 Thread Sameera Medagammaddegedara
Some additional suggestions for organizing the above code: <% (function(request,response){ var method = request.getMethod(); function doGet(req,res) { } switch(method) { case 'GET': doGet(request,response); break; default:

Re: [Dev] Invoking a Jaggery api via HttpURLConnection

2016-09-23 Thread Sameera Medagammaddegedara
EDIT: Please post the error you get afterwards. On Fri, Sep 23, 2016 at 5:11 PM, Sameera Medagammaddegedara < samee...@wso2.com> wrote: > Hi Denuwanthi, > > Can you please change your jag to the following: > > <% > try { > > } catch (e) { > log.error(e); > response.status=500; >

Re: [Dev] Invoking a Jaggery api via HttpURLConnection

2016-09-23 Thread Sameera Medagammaddegedara
Hi Denuwanthi, Can you please change your jag to the following: <% try { } catch (e) { log.error(e); response.status=500; var msg = {}; msg.status = 500; msg.error = "Failed invoking remote endpoint"; print(msg); } %> On Fri, Sep 23, 2016 at 5:04 PM, Denuwanthi

[Dev] Invoking a Jaggery api via HttpURLConnection

2016-09-23 Thread Denuwanthi De Silva
Hi, I have .jsp file, in which I want to invoke a jaggery api. The content inside .jsp file is as below: URL url = new URL(baseURL + *"/user-login/user/authenticate/add*?scope=" + URLEncoder.encode(scope, "UTF-8") + "=" + redirectUri + "=" + clientId + "=" + arc + "=" + responseType + "=" +