Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RESTAPI get node

Status
Not open for further replies.

alipkok

IS-IT--Management
Dec 1, 2015
9
0
0
DE
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 ...
 
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
 
Thanks Appu.I use a dev environment where i login as admin .What are the next steps?
 
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="[URL unfurl="true"]http://code.jquery.com/jquery-1.11.1.min.js"></script>[/URL] -->

<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://[b][COLOR=#EF2929]<yourserver>[/color][/b]/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-[URL unfurl="true"]www-form-urlencoded",[/URL]
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
[COLOR=#CC0000][b]var myBody = { type: "0", parent_id: placeFolderGetsCreated, name: "TEST REST API" };[/b][/color]
$(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://[b][COLOR=#EF2929]<yourserver>[/color][/b]/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
 
Thanks a lot Appu , really appreciate your help.
I will try it !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top