"/rest/api/2/search" works, but when I add a parameter it says Unauhtorized


When I run the following code, it goes through successfully:

RestRequest request = new RestRequest("/rest/api/2/search") { Method = Method.GET };
var response = client.Execute(request);

This returns a list of all of the issues. However, if I try to get issues by Project Key like the following:

RestRequest request = new RestRequest("/rest/api/2/search?jql=\"KEY\"") { Method = Method.GET };
var response = client.Execute(request);

This gives me an unauthorized error.

Is it a setting in the project itself that I need to fix to allow this? I’m sure I am authenticating right since the first call works fine and many other calls are working as well.

Hi @jhalter,

To have a better context of the problem, I have two questions:

  1. This is for which Jira deployment: server or cloud?
  2. What is your exact JQL? Is it just "KEY"?



  1. Server
  2. Yes, it is just “KEY” where KEY is the name of the project that I want to get the issues for.

Thanks for your help.

I would recommend getting the jql right in product and then using it in the rest API. I think the JQL you want is:

project = KEY

Even so, unauthorised seems wrong as an error message.

Lets start by fixing what we see wrong and then we start looking into other things. So please correct JQL query as suggested in the above answers.

I have edited my code like so:

RestRequest request = new RestRequest("/rest/api/2/search?jql=project=KEY") { Method = Method.GET };
var response = client.Execute(request);

However I am still getting an unauthorized error. Once again, if I cut out the JQL part, I get the list of results with no issues.

Hi @jhalter,

To isolate this scenario, can you check what is the result when you call the REST API with query parameters via CLI using basic auth? I’m looking for two possible outcomes:

  1. Successful response - this means that the user has no problem accessing the resource and we can deduce that the problem lies somewhere else. We can start looking at the rest client and/or how it was setup (auth used, etc.). This post might be helpful.

  2. It throws an unauthorized error - kindly try using Jira’s Permission Helper (Administration -> System -> Admin Helper -> Permission Helper) and see if there are some more unusual Browse Project permission errors for that specific user; although not having permissions should only return an empty result set and not an unauthorized response, I just want to cover all the bases in case I missed on anything. If there are red X marks, please try to fix them. Once the results of the Permission Helper test is all green and running the search REST API via CLI still throws an unauthorized error, kindly create an issue in the Developer Support service desk.


My deduction to this says that anonymous user may not have access to jql, try putting in credentials of a user who has access to the instance and can search on project that you are using in jql.

Hello @saurabh.gupta, for anonymous users or invalid credentials, search REST API returns a 200 with an empty result set.