Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira REST API query for projects comes back empty

I'm writing a JavaScript app that generates a report across all out projects for my team. One of the roadblocks I'm facing is CORS when querying the JIRA REST API.

One workaround I'm currently trying is that I set up a node.js server that gets a proper session using my credentials and then tries to get all projects (via /rest/api/latest/project/). 

The node.js app retrieves a proper session id. However, when it tries to query for all projects, the answer is always empty (as if it failed to authenticate properly).

This is the raw response, I marked some sensitive information with Xs:

{data: [ ],
status: 200,
statusText: "OK",
headers: {server: "nginx",
date: "Mon, 04 Apr 2016 22:58:24 GMT",
content-type: "application/json;charset=UTF-8",
transfer-encoding: "chunked",
connection: "close",
vary: "Accept-Encoding",
x-arequestid: "58x134005x1",
x-asessionid: "gbbla4",
x-asen: "SEN-3321953",
x-ausername: "anonymous",
x-atenant-id: "XXXXX.atlassian.net",
cache-control: "no-cache, no-store, no-transform",
x-content-type-options: "nosniff",
set-cookie: ["atlassian.xsrf.token=BJY0-9ZH5-270Y-1S6C|449aa35483219b58564XXXXXXXXXXXXXXXXXXX|lout; Path=/; Secure"
],
strict-transport-security: "max-age=315360000;includeSubDomains"
},
config: {transformRequest: { },
transformResponse: { },
headers: {Accept: "application/json, text/plain, */*",
cookie: "JSESSIONID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
Content-Type: "application/json",
User-Agent: "axios/0.9.1"
},
timeout: 0,
xsrfCookieName: "XSRF-TOKEN",
xsrfHeaderName: "X-XSRF-TOKEN",
method: "get",
url: "https://XXXXXXX.atlassian.net/rest/api/latest/project"
}
}

What confuses me the most is that x-ausername is anonymous, even though I appear to be properly authenticated. That's probably why the project list is empty (because I cannot see them).

But why is that? When I call the URL in my browser the JSON is returned just fine.

I'd be very grateful for insights on how to get this running. I already spent way more time on this than I wanted. 

 

Thanks in advance,

Fred

1 answer

Hi Fred,

Try to use /rest/api/2/project instead of /rest/api/latest/project.
In case this won't help. Check the authorization method. It seems that you're not authenticated properly. Do you use JWT as the authentication mechanism?

Hi Aleks,

thanks or the quick reply. I changed the URL but that didn't help. No, I'm not using JWT since this is not an add-on. I thought it would not be necessary to go that deep just to query our projects. Is JWT really necessary for that kind of interaction?

Hi Fred,

I am facing the same issue. Have you found the solution to your problem?

Same poblem using .NET and WebRequest.

Response come with ContentLength: -1 and HttpStatusCode: 200 (OK).

https://my.jira.domain/rest/api/2/search?jql=%20project=%22MY%22%20AND%20issuetype=%22epic%22

Same request in Chrome returns a normal data.

Request have worked a several days ago.

Requests without jql works fine: https://my.jira.domain/rest/api/2/project/10001

Facing the same issue...

Probably has to do something with the cookies, as if you run it in incognito mode (chrome) it will not work as well

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

4,013 views 11 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you