Hello all I'm using Jira 4.4.
I'm trying to make a plugin that performs some simple jql queryies via RESt.
In order to do so I need to log in Jira with my plug in.
How do I have to do?
I tried in two different way
1) Java Script
<form method="POST">
Username: <input type="text" name="username" /> <br />
Password: <input type="password" name="password" /> <br />
<input type="button" value="Check In" name="Submit" onclick=javascript:login(username.value,"username",password.value,"password") >
</form>
</form>
<script language = "javascript">
function login(username, password) {
var url = "http://172.16.1.24/jira/rest/auth/1/session";
var JSONObject = {"username": ""+username+"", "password": ""+password+""};
var client = new XMLHttpRequest();
client.open("POST", url, false);
client.setRequestHeader("Content-Type", "application/json");
client.send(JSONObject);
if (client.status == 200)
alert("The request succeeded!\n\nThe response representation was:\n\n" + client.responseText)
else
alert("The request did not succeed!\n\nThe response status was: " + client.status + " " + client.statusText + ".");
}
</script>
And a second one using Java (I'm using Play!Framework)
String wsReq = "{\"username\": \""+username+"\", \"password\": \""+password+"\"}";
HttpResponse response = WS.url("http://172.16.1.24/jira/rest/auth/1/session").setHeader("Content-Type", "application/json").body(wsReq).post();
with the first one I don't get any answer from the server, with second one I'm authenticated but non session information are stored and I cant make any other request.
Somewhere I read that I have to use the session ID in order to make others api calls. But where I put it if, as an example, I point to the url myhost/jira/rest/api/2.0.alpha1/searches