Why does Cloud Rest API always return 401?

Elena Bolpachova October 18, 2019

Hey guys! 

So for about a couple of months now on and off, I've been trying to make a tiny little C# console web app to filter through our Jira Cloud instance for open bugs, download their error logs, dump them in the description and then check if any other bugs have the same error and link them as duplicates. 

I've read through the documentation - https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302

I tried with my user, because I am an admin for the project, I tried with another user I created which I also made an admin, but in both cases, when I try running Postman GET for the filter ID, with basic auth, it works, but when I try it from my console app, it returns a 401. 

I even tried with cURL and got the same result... 

Perhaps I should be using these api tokens, but I tried once with one and didn't work either... 

Many thanks in advance for your help! 

2 answers

0 votes
Cristian Rosas [Tecnofor]
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.
October 18, 2019
0 votes
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2019

@Elena BolpachovaAPI Token are must for accessing Jira cloud rest API using BasicAuthenticatoin.

Here is curl example,

curl --request GET \
--url 'https://<SITE_NAME>.atlassian.net/rest/api/3/issue/<SOME_ISSUE_KEY>' \
--user '<EMAIL>:<API_TOKE>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'

 

In above snippet, replace

  • <SITE_NAME> with your site name
  • <SOME_ISSUE_KEY> with issue key you want to fetch (you have later use JQL if single issue key works fine)
  • <EMAIL> your email id, you are using for login
  • <API_TOKE> api token generated in your account using same email that you are using for login

 

Also, if you can share CURL command you are using I can assist.

Elena Bolpachova October 18, 2019

Thanks @DPKJ ! 

The issue was Windows doesn't like curl's single quotes :D 

My only follow up would be, once I get the filter, how do I get the issue Ids from it? Can the Columns property help me?

Thanks again! 


curl --request GET --url "https://mycompanysite.atlassian.net/rest/api/3/filter/10023"

--ssl

--user "elena.bolpachova@companydomain.com:token"

--header "Accept: application/json"
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2019

@Elena BolpachovaMy bad, was on Linux.

 

When you call a filter API it return detail of filter and not issues in filter. But the JSON response of filter API will contain a key name "searchUrl" you can use this URL and make another request to get issues in filter. I am attaching a sample JSON response of filter API for reference.

Screenshot 2019-10-18 at 4.02.47 PM.png

 

This 'searchUrl' is basically calling search API. Reference here - https://developer.atlassian.com/cloud/jira/platform/rest/v3/?#api-group-Issue-search

Suggest an answer

Log in or Sign up to answer