how can I use JSESSIONID to get any issue by using jira api

Prashant_Shri July 12, 2019

Hi,

I have used "/rest/auth/1/session" rest call with my credentials  to get session id. and it has provided me the json like -

{
"session": {
"name": "JSESSIONID",
"value": "42424424242342434234.node1"
},
"loginInfo": {
"failedLoginCount": 6,
"loginCount": 356,
"lastFailedLoginTime": "2019-07-09T08:55:26.560+0000",
"previousLoginTime": "2019-07-11T17:42:08.837+0000"
}

now i want to use this session to get all tickets assigned to me in jira. how do i send this session with my other rest call to get tickets detail. 

 

Thanks in advance. 

1 answer

0 votes
Rafael Pinto Sperafico
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2019

Hi @Prashant_Shri ,

Please, refer to https://developer.atlassian.com/server/jira/platform/cookie-based-authentication/ as it demonstrate on how to set up the cookie with JSESSIONID retrieved.

Then, to get all the tickets assign to you, you could run Jira's search REST API endpoint using JQL https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/search using the JSESSION in the request header.

If you are working with a language that is not in the documentation mentioned, please specify the language and we from Atlassian Community can comment on with source code example.

Kind regards,

Rafael

Seyid Aghayev November 29, 2020

What if I want to set the cookie with JSESSIONID when I make Javascript XMLHttpRequest? Is it impossible? I only see an example for Nodejs. If it is impossible, what is the correct way to make XMLHttpRequests from Javascript to Jira Rest Api?  

Sandip Mazumder September 10, 2023

 

I retrieved the current JSESIONID using "/rest/auth/1/session", then created a httpwebrequest.cookiecontainer object and added the cookie JSESSIONID with the session id using the below code, but it is failing . The code works perfectly if I replace the two lines of codes related to cookies with the basic authentication using userid/pswd.

WebRequest request = WebRequest.Create(url);

request.CookieContainer = new CookieContainer();

request.CookieContainer.Add(url, new cookie("JSESSIONID", sessionID);

WebResponse response = request.GetResponse();

The program is going to catch block after the above line.

// sessionID is a string variable holding the jsession id value. url contains the jira issue url which works perfectly if used in browser

Can anyone share the right way to use jsessionid using C-Sharp or share a working code snippet.

Suggest an answer

Log in or Sign up to answer