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

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

Getting response error (400) when contacting REST API through JIRA API TOKEN

Trying to make a GET request to the REST API using Jira API token. Works on the browser through google extensions using the SAME token. I literally copied the request to make sure I was not messing something up. Yet, it doesn't work still.

 

My request:

 

Method: GET,

URL: https://jiracloud.COMPANY.com.br//rest/api/2/search?fields=fields,key&jql=worklogAuthor=currentUser(),
Headers: {

   "content-type": "application/json",

   "cache-control": "no-cache",

    "app_token": "myToken"
}

 

Through the browser and/or Google Extensions that makes this same request I receive:


Status: 200

 

Through Postman or any code OUTSIDE the browser:

Status: 400,

Error: "Field 'worklogAuthor' does not exist or this field cannot be viewed by anonymous users."

 

I tried everything I could think of, don't know what else to do. Tried even using the the same "User-Agent" and Cookies as the browser uses to make the request...What am I missing? It must be something really obvious. 

Thanks

2 answers

1 accepted

0 votes
Answer accepted

The reason that you're able to make API calls from your browser is because of the session data stored in cookies. Replicating the exact cookie jar and request details coming from your browser in a REST API client like Postman isn't an exact science.

The recommendation would be to use basic authorization for making REST API calls in Postman.

If you're running Jira Server (on-prem): https://developer.atlassian.com/server/jira/platform/basic-authentication/ 

If you're making a call against Jira Cloud, you'd use basic auth but with an API token:
https://developer.atlassian.com/cloud/jira/software/basic-auth-for-rest-apis/

Thank you. If possible can you give me a hint on how can I find out if I'm dealing with Jira server or Jira Cloud? From the url of my company it seems like I'm dealing with cloud, since it's `jiracloud.mycompany.com`. Am I correct or there's another way to find this out?

@Bruno Mayol Giannoti sure.. just hit the /rest/api/2/serverInfo endpoint, and if you see deploymentType: "Cloud" then it's a cloud instance.

For example: https://ecosystem.atlassian.net/rest/api/2/serverInfo

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

727 views 7 24
Read article

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