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

10 comments
Comment actions Permalink

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);    
          }  
     }
}
0
Comment actions Permalink

Hi Vadim

Cool thanks for the example. I will have to have a play with that :-)

Regards

Patrick

0
Comment actions Permalink
Hi Folks,

I try to use the YouTrack REST API.

I've used the example above.

Login worked, after problems with the cookies. But only if you have enabled the Guest Acount.

No problems when creating a Issues.

My problem is now to get a Issue.

I have tried: http://localhost:8080/youtrack/rest/issue/XX-1

But the status code is 404

Has anything changed?

And is it possible to use the query language?

For example: http://localhost:8080/youtrack/rest/issues?q=state% 3A% 3A assignee me

Thank you very much

Greets
0
Comment actions Permalink

When using the REST are developers posting to their own instance of YouTrack or are they using the JetBrains Instance ?

0
Comment actions Permalink

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

0
Comment actions Permalink

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.

0
Comment actions Permalink
Hi,

Thanks for your answer.

I tried this with the current EAP (Build #67), but i have still a 404 Error.

Greets
0
Comment actions Permalink

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

0
Comment actions Permalink

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.

0

Please sign in to leave a comment.