FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Dec 25, 2011, 2:06 PM
7 Posts

REST Service

  • Category: Extension Library
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: rest service,JSON
  • Replies: 5
Is it possible to get a handle to the REST service to use as a data source to other objects instead of the dojogrid?
 
Thank you.
Dec 27, 2011, 2:35 PM
150 Posts
Re: REST Service
 
The REST service can be used by many controls, check the Extlib demo database.
the REST service give you domino data in different formats like JSON,
 
please be more specific 
Dec 27, 2011, 4:46 PM
7 Posts
Re: REST Service
Thomas,
 
All of the examples just open a new page displaying the JSON data.  Am I missing something?  How can I get the JSON object to use in a repeat control? 
 
Thank you.
Dec 29, 2011, 6:33 AM
150 Posts
Re: REST Service
 
You can use java to get the json as a string and then try and convert it to an object or array/vector to use in your repeat.
Below code will return any webpage into a string, put it in a computedValue and try it out. 
 
var u:java.net.URL  = new java.net.URL("http://localhost/mydb.nsf/start.xsp/myjson");
var br:BufferedReader= new java.io.BufferedReader(new java.io.InputStreamReader(u.openStream()));
var tmp="";
while(br.readLine() != null){
    tmp+= br.readLine();
}
tmp 
 
 
Good Luck
Thomas Adrian 
http://www.intrapages.com 
 
 
 
Dec 29, 2011, 9:43 AM
7 Posts
Re: REST Service
Thomas,
 
Thank you for the information.  I am basically using that method now but with the Domino Data Services instead of the REST Service.  
 
I did find one interesting this  the HttpURLConnections was not authenticating me. I had to add the following:
 
var auth="<user>:<pass>"
conn.setRequestProperty("Authorization","Basic " + new sun.misc.BASE64Encoder().encode(auth.getBytes()));
conn.connect();
 
and then everything works fine.  Why do I have to do this?
 
Thank you.
 
Jan 2, 2012, 4:27 AM
272 Posts
Re: REST Service
This is the normal behavior. The server needs user credentials if the target website requires authentication.
 
Sven
 

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.