INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

RESTAPI get node

RESTAPI get node

(OP)
Hello,
first to mention that im not a developer, thus im not very familiar with RESTAPI and scripting in general (basic JS knowledge).I would like to have node information in a json format using url like when im using the following URL ?func=ll&objId=2000&objAction=page&noGUI=true where i receive information in JSON .
Is it possible?
Can i have something similar with RESTAPI ?
When im using the following : /otcs/cs.exe/api/v1/nodes/2000/nodes i receive the following error : 401 - Unauthorized: Access is denied due to invalid credentials.
I went through REST API quick guide but im not sure that i understood what is needed ...

RE: RESTAPI get node

That is typical because a 401 indicates the ll website is a IWA resource,rest needs a OT header built into the call so your script should invoke it against a userid/password kind of livelink.
RESTAPI is designed to be executed from any place so it is a security constraint built into it.If you touch base with your organizations admin and ask for a server that they use to login as user 'Admin'
and a password,if they create you a similar login account this is easier.Otherwise it will be slightly difficult against IWA servers.(Not to say it can be worked but more setup things)

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
http://www.tek-tips.com/faqs.cfm?fid=2884
http://www.linkedin.com/in/appunair
http://www.livelink.in

RE: RESTAPI get node

(OP)
Thanks Appu.I use a dev environment where i login as admin .What are the next steps?

RE: RESTAPI get node

There are two places I know that explain to rest api developers the theory and practice
One is the KB Discussions forum needs you have a valid account with OT .knowledge.opentext.com
The other one is developer.opentext.com which is a freebie site has some info.I don't do a lot of REST but I know what it is doing
The main Livelink that looks like this /otcs/cs.exe where you see the login prompt is a web served application when you login using a
browser you get a in memory cookie until you close that you are good.It is very easy to take this cookie and use it without ever logging into
the LL application.the programming world calls this CORS attack so to prevent that the OT RH that looks like this /otcs/cs.exe/api/v1/nodes/2000/nodes
will not belive your cookie but would want a new tag called the headers tag.How i test this code is first I create a custom view object in livelink and make sure
the buttons work,then when I am sure it works I copy the html file locally and uncomment the Jquery line the $ stuff is all Jquery dependent and \how it used to work in Livelink it will work outside as well.

anyaways here is an extremely simple implementation of the REST API

CODE -->

<META http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<!-- Remove this JQuery source line if this page is existing stand alone not in livelink as Livelink already has the Jquery loaded -->
<!-- <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> -->

<SCRIPT LANGUAGE="javascript">
//change this and the post URL  look at the form tag to your livelink server who is not a IWA resource in other words 
//if you click on its URL you get a userid/password box in our parlance this is called anonymous access
var myTicket;
var baseURL='http://<yourserver>/CS16/livelink.exe';
var credentials = { userName: "Admin", password: "livelink" };
//this is an existing folder ID in livelink so if this is successful only one will get created
//you have to change the name or basically remove what got created in a successful run
var placeFolderGetsCreated=66033;

function TestUser ( ) {
$(document).ready(function(){
var url = baseURL+'/api/v1/auth';
$.support.cors = true;
$.ajax({
url:url,
type:"POST",
crossDomain: true,
data:credentials,
dataType:"json",
contentType: "application/x-www-form-urlencoded",
success:function(res){
alert("Ticket=" + res.ticket);
myTicket = res.ticket;
},
error:function(res){
alert("Bad thing happened! " + res.statusText);
}
});
});
}





function CreateFolder ( ) {
alert(myTicket);
//0 means folder subtype,where it needs to be done,the name you would like to happen
//any rest api thing that you find in documentation can be called and its output will be JSON
//JSON parsing is not OT's job but the developers job you can google for any thing you want about it
var myBody = { type: "0", parent_id: placeFolderGetsCreated, name: "TEST REST API" };
$(document).ready(function(){

var url = baseURL+'/api/v1/nodes';
$.support.cors = true;
$.ajax({
url:url,
type:"POST",
crossDomain: true,
data:myBody,
dataType:"json",
headers: { "OTCSTICKET": myTicket },
success:function(res){
alert("success!");
alert("Folder object id = " + res.id);
},
error:function(res){
alert("Bad thing happened! " + res.statusText);
}
});
});
}
</SCRIPT>
<form action="http://<yourserver>/CS16/livelink.exe" method="post" name="myForm">
<p><input class="button" onclick="TestUser()" type="BUTTON" value="Get Cookie" /></p>
<p><input class="button" onclick="CreateFolder()" type="BUTTON" value="Create Folder" /></p></form> 


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
http://www.tek-tips.com/faqs.cfm?fid=2884
http://www.linkedin.com/in/appunair
http://www.livelink.in

RE: RESTAPI get node

(OP)
Thanks a lot Appu , really appreciate your help.
I will try it !

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close