Hi Rajeenthini, Instead of the DAS REST API, you can use the "Analytics javascript API" [1]. This should eliminate the requirement of needing user-credentials. (or doesn't need to send an Authorization header)
[1] https://docs.wso2.com/display/DAS300/Analytics+JavaScript+(JS)+API Regards, Supun On Fri, Dec 18, 2015 at 10:41 AM, Rajeenthini Satkunam <rajeenth...@wso2.com > wrote: > Hi all, > > Currently I am working on creating sample for dashboard server with DAS > integration.I need to invoke DAS rest API from Jaggery file(sample.jag) to > get some data.As per documentation[1] of DAS rest API we need to send > authorization header along with request to fetch data from DAS. So for > workaround I have hard-coded the username password values to variable and > concatenate them as username + ":" + password and encoded them then send as > a authorization header.Here I need to get server username and > password(credentials).IMHO it is not good practice that hard-coding > credentials of server. > I have shared my Jaggery code below > > try { > var username = "admin";//hard-coded value of username > var password = "admin";//hard-coded value of password > var tableName = request.getParameter("tableName"); > var query = request.getParameter("query"); > var url = "https://localhost:9465/analytics/search"; > var encoderJavaPkg = Packages.javax.xml.bind.DatatypeConverter; > var bytes = []; > var encodeString = username + ":" + password; > for (var i = 0; i < encodeString.length; ++i) { > bytes.push(encodeString.charCodeAt(i)); > } > var authHeader = "Basic " + encoderJavaPkg.printBase64Binary(bytes); > var result = post(url, stringify({ > "tableName": tableName, > "start": 0, > "count": 100, > "query": query > }), {"Authorization": authHeader, "Content-Type": "application/json"}, > "application/json"); > print(result.data); > } catch (e) { > log.info(e); > } > > [1] - > https://docs.wso2.com/display/DAS300/Retrieving+All+Records+Matching+the+Given+Search+Query+via+REST+API > > As for now to start both server (DAS and DS) I have changed offset value for > DAS as "2" in carbon.xml.I can successfully start both server > simultaneously.It will be very useful if I can get the back-end URL and > server credentials of DAS and get rid of hard-coding those values.Can anyone > please help me and your suggestions mostly appreciate? > > > > > -- > > *Thank You.* > > *Rajeenthini Satkunam* > > *Associate Software Engineer | WSO2* > > > *E:rajeenth...@wso2.com <rajeenth...@wso2.com>* > > *M :+94770832823 <%2B94770832823> * > > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- *Supun Sethunga* Software Engineer WSO2, Inc. http://wso2.com/ lean | enterprise | middleware Mobile : +94 716546324
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev