- Community Home
- >
- Software
- >
- Products
- >
- Quality Center / ALM
- >
- Quality Center Support and News Forum
- >
- How to access ALM data using REST API
- Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-11-2011 12:31 AM
can anyone tell me how to access ALM data using REST API? Is there any java code example available?
Thanks in advance.
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-14-2011 11:37 AM
You can find the ALM 11.0 REST API reference guide here:
http://support.openview.hp.com/selfsolve/manuals
http://support.openview.hp.com/selfsolve/document/
ST_API.html?searchIdentifier=-765a98c0%3a12de84ca1
In the documentation you will find examples how to use Rest resources.
The main entry point it the authentication after then you can login to project, create entities and more using the exposed resources.
To consume it from Java read here:
http://blogs.sun.com/enterprisetechtips/entry/cons
Thanks,
Elad
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-14-2011 11:18 PM
ST_API.html?searchIdentifier=-765a98c0%3a12de84ca1
I can't see any examples of using Rest resources, Could you please be more specific?
Re: How to access ALM data using REST API
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-16-2011
03:47 PM
- last edited on
02-24-2012
04:59 AM
by
BGroot
I figured out. please see:
http://forums13.itrc.hp.com/service/forums/questio
Edited by Bill Groot:
The above link is an old ITRC link and will not work. I have found the thread so to see it please click on this link:
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-01-2011 09:45 AM
Unfortunately the last link is not valid anymore. Did someone manage to login via the Java API to HP-ALM? If yes may I ask you to send me the source code. Thanks a lot for any help.
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-07-2012 12:24 PM
Did you get the ALM REST API working? I'm seeking the .jar file to import into java servlets.
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-08-2012 04:13 AM
Yes I found a way that is working. You can find the necessary files in the attached ZIP files.
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-10-2012 08:03 PM
>Unfortunately the last link is not valid anymore.
Looking at Justin's other topic, it's probably:
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-24-2012 08:09 AM
What you can try:
Retype the address. "
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-31-2012 09:15 AM
I have developed a framework able to connect in ALM via restful. Please check it:
Api fo JAVA
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-30-2012 09:37 AM
I get a 403 error when I try to navigate to the Google Code link you posted with your java alm rest api example. Can you repost the link?
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-29-2013 06:07 AM
I got 404 when i clicked teh google code link. Could you please give the correct link ?
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-26-2013 04:36 AM
I get proxy errors and missing page messages. I thought this was HP's SUOPPORT site? Not very impressive work, gentlemen!
Re: How to access ALM data using REST API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-02-2013 11:23 PM
>I thought this was HP's SUPPORT site?
No, this is a peer to peer forum, not an official HP support site.
Re: How to access ALM data using REST API
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-04-2013 08:06 AM - edited 03-04-2013 08:10 AM
I've created a C# app that can authenticate, get and post to ALM REST API.
Should be very similar on Java.
Additionaly there are examples on JAVA in ALM REST API reference in ALM documant library.
Auth method:
public void auth(string url, string xml)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(xml.ToString()) ;
req.Method = "POST";
req.ContentType = "application/xml";
req.Accept = "application/xml";
req.KeepAlive = true;
req.AllowAutoRedirect = true;
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
backstr = sr.ReadToEnd();
myheader = res.Headers.Get("Set-Cookie");
sr.Close();
res.Close();
}The tricky thing here that when you athenticate yourself you recieva a cookie that you SHOULD use further, when you do posts or gets.
But ALM returns you cookies NOT in http.cookie, but in HTTP response HEADER itself with name "Set-cookie".
So my header would be here:
myheader = res.Headers.Get("Set-Cookie"); So now we call out auth method:
try
{
// my creds, server domain etc are taken form apps UI.
server_ = textBox2.Text;
user_ = textBox5.Text;
password_ = textBox6.Text;
domain_ = textBox3.Text;
project = textBox4.Text;
REST.auth(server_ + "/authentication-point/alm-authenticate", "<?xml version='1.0' encoding='utf-8'?><alm-authentication><user>" + user_ + "</user><password>" + password_ + "</password></alm-authentication>");
MessageBox.Show("Connected to REST");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}Here is get method:
public void get(string url)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
req.Accept = "application/xml";
req.KeepAlive = true;
req.AllowAutoRedirect = true;
req.Headers.Add("Cookie", myheader);
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
backstr = sr.ReadToEnd();
sr.Close();
res.Close();
}So we add our header that we recieved after auth like : req.Headers.Add("Cookie", myheader);
cookie is stroed in myheader variable as we remember, right?
So here example of getting defects from ALM:
try
{
// again creds, server, domain,etc. are taken from my apps variables.
REST.get(server_ + "/rest/domains/" + domain_ +"/projects/" + project + "/defects/?page-size=1000");
XPARSER.readXml(REST.backstr); // here I parse the response as I recieve xml - ignore that and everuthing that is below - it's relevant for my app.
for (int i = 0; i < XPARSER.ids.Count; i++)
{
listBox1.Items.Add(String.Format("{0} {1}", XPARSER.ids[i], XPARSER.names[i]));
}
XPARSER.ids.Clear();
XPARSER.names.Clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}Here is post method:
public void post(string url, string xml)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(xml.ToString()) ;
req.Method = "POST";
req.ContentType = "application/xml";
req.Accept = "application/xml";
req.KeepAlive = true;
req.AllowAutoRedirect = true;
req.Headers.Add("Cookie", myheader);
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
backstr = sr.ReadToEnd();
sr.Close();
res.Close();
}When you want to create something you should send post http request.
Along with url you should provide an XML of an entity you are tying to post.
If you don't know how xml should look like - do a get request first
- recieve an xml and see how it looks like.
Here is example of posting a defect:
try
{
for (int i = 0; i < rest_bCount; ++i)
{
REST.post(server_ + "/rest/domains/" + domain_ + "/projects/" + project + "/defects/",
@"<?xml version='1.0' encoding='utf-8'?>
<Entity Type='defect'>
<Fields>
<Field Name='description'>
<Value>desc</Value>
</Field>
<Field Name='name'>
<Value>defect created from rest" + i + Convert.ToString(rand.Next()) + "</Value></Field><Field Name='status'><Value>" + arr[i % arr.Length] + "</Value></Field><Field Name='severity'><Value>" + arr2[i % arr2.Length] + "</Value></Field><Field Name='detected-by'><Value>" + user_ + "</Value></Field><Field Name='creation-time'><Value>" + date.ToString(format) + "</Value></Field></Fields></Entity>"
);
XPARSER.readXml(REST.backstr);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}Hope that will help you a bit.
