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

Why does Cloud Rest API always return 401?

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
DPK J Community Leader Oct 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.

Thanks @DPK J ! 

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"
DPK J Community Leader Oct 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
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

273 views 1 2
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