Is it possible to access Charisma programmatically?
Hi All
I was just wondering if it was possible to access Charisma programmatically? I noticed that there is a jetbrains exception reporter which manages to send exceptions into charisma so now I'm wondering if there is a possiblity for my own applications to do the same thing to my local version of charisma? If so then I'd like to know where to find the API description / docs / suggestions.
Thanks
Patrick
Please sign in to leave a comment.
Hi, Patrick!
Charisma has REST API, but it's not documented yet.
Here is sample java code for posting issue into charisma. It uses jakarta http client.
public class REST_Test extends TestCase {
public static String local = "http://localhost:8080/charisma";
public static String teamsys = "http://teamsys.labs.intellij.net/teamsys";
public static String login = "/rest/user/login"; public static String issue = "XX-1";
public static String getissue = "/rest/issue/" + REST_Test.issue;
public static String postissue = "/rest/issue/";
public static String charisma = REST_Test.local;
public void test_loginAndGet() throws Exception {
HttpClient c = new HttpClient();
this.login(c);
this.getissue(c);
}
public void test_loginAndPost() throws Exception {
HttpClient c = new HttpClient();
this.login(c);
this.postissue(c);
}
public void login(HttpClient c) {
try {
PostMethod p = new PostMethod(REST_Test.charisma + REST_Test.login);
p.addParameter("login", "admin");
p.addParameter("password", "admin");
c.executeMethod(p);
System.out.println(p.getResponseBodyAsString());
Assert.assertEquals(p.getStatusCode(), 200);
Assert.assertTrue(p.getResponseBodyAsString().indexOf("ok") > 0);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void getissue(HttpClient c) {
try {
GetMethod g = new GetMethod(REST_Test.charisma + REST_Test.getissue);
c.executeMethod(g);
System.out.println(g.getResponseBodyAsString());
Assert.assertTrue(g.getStatusCode() == 200);
Assert.assertTrue(g.getResponseBodyAsString().indexOf(REST_Test.issue) > 0);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void postissue(HttpClient c) {
try {
PostMethod p = new PostMethod(REST_Test.charisma + REST_Test.postissue);
p.addParameter("project", "XX");
p.addParameter("summary", "testsummary");
c.executeMethod(p);
System.out.println(p.getResponseBodyAsString());
Assert.assertEquals(p.getStatusCode(), 200);
Assert.assertTrue(p.getResponseBodyAsString().indexOf("testsummary") > 0);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Hi Vadim
Cool thanks for the example. I will have to have a play with that :-)
Regards
Patrick
When using the REST are developers posting to their own instance of YouTrack or are they using the JetBrains Instance ?
Hi again,
Url for get Issue by ID:
http://localhost:8181/youtrack/rest/issue/byid/XX-1
Now, I'm still looking for how to filter issues.
Greets
It depends on URL parameter of PostMethod constructor. If it points to developers own instance of YouTrack it will post an issue to her own tracker, if it points to JetBrains instance it will post to our tracker.
Get issues by query
http://localhost:8181/youtrack/rest/project/issues/XX?filter=<query here>
Hello Hans,
works for me - http://localhost:8081/rest/project/issues/YP?filter=state:%20Open
I think you are not removing "youtrack" from the Maxim's example:
- looks like it's the virtual directory where he has installed YouTrack (instead of in the root as I did, and probably you too). It also took me a while to figure this out :-)
Hope that helps.
Alexey
my 2 cents: for non-Java implementations, you have to keep in mind that you should reuse the cookie returned by login POST in the following requests. See more details here.