Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

With curl, how can I determine what Jira I'm using?

Jason Hunter November 23, 2023

I have several Jira instances and some of them are at work.  I need to know if they are Jira Cloud or Jira Server, using only curl or similar tool, without loggin in;)

 

The reason I'm asking is because I have problems logging in with my Personal Access Token (302 Redirect) and to ask a good question, I need to know what Jira I'm asking;)

 

 

2 answers

1 accepted

2 votes
Answer accepted
Matthias Gaiser _K15t_
Community Champion
November 23, 2023

Hi @Jason Hunter

you can use the serverInfo rest endpoint for that. That one also doesn't need authentication.

The curl command would look like that:

curl --request GET \
  --url 'https://ecosystem.atlassian.net/rest/api/3/serverInfo' \
  --header 'Accept: application/json'

This returns something like this:

{
"baseUrl": "https://ecosystem.atlassian.net",
"displayUrl": "https://ecosystem.atlassian.net",
"displayUrlServicedeskHelpCenter": "https://ecosystem.atlassian.net",
"version": "1001.0.0-SNAPSHOT",
"versionNumbers": [ 1001, 0, 0],
"deploymentType": "Cloud",
"buildNumber": 100242,
"buildDate": "2023-11-22T18:28:19.000-0600",
"scmInfo": "28471e573eec8495fd31d4570bca6ecd00da1242",
"serverTitle": "Ecosystem Jira",
"defaultLocale": { "locale": "en_US" },
"serverTimeZone": "Etc/UTC"
}

The attribute deploymentType has the value Cloud if it's a Jira Cloud. If it's missing or has another value, the instance is a Server/Data Center instance.

Cheers,
Matthias.

Jason Hunter February 14, 2024

I'm not getting any output from curl when I issue that command.

Can the path be something different than

/rest/api/3/serverInfo

The JIRA instance is running here:

JIRA 

 

 

Like Matthias Gaiser _K15t_ likes this
Matthias Gaiser _K15t_
Community Champion
February 14, 2024

@Jason Hunter - that's because it's a Data Center instance, try it with the version 2 API:

https://jira.eg.dk/rest/api/2/serverInfo

Like Jason Hunter likes this
Jason Hunter February 14, 2024

That's just great, thanks;)

Just for contextual knowledge, is using a token against such Data Center instance the same as I've found for the cloud instance?

```

echo "" > ~/.netrc-for-atlassian
chmod 600 ~/.netrc-for-atlassian
echo "machine jira.eg.dk login <my.name@email.address> account <64-bit token" >> ~/.netrc-for-atlassian

curl -n ~/.netrc-for-atlassian https://jira.eg.dk/rest/api/2/issue/

```

Like Matthias Gaiser _K15t_ likes this
Matthias Gaiser _K15t_
Community Champion
February 14, 2024

The usage for a Data Center instance is a bit different. You find more details about PATs for DC in this documentation. The main difference is that you need to pass the token as a bearer token. Here's a quote from the docs:

To use a personal access token for authentication, you have to pass it as a bearer token in the Authorization header of a REST API call.

Here's an example using cURL to call the REST API with a bearer token: 

curl -H "Authorization: Bearer <yourToken>" https://{baseUrlOfYourInstance}/rest/api/content
Jason Hunter February 14, 2024

Thanks a lot.

 

Everything works perfectly now;)

 

Thanks again.

 

 

 

 

0 votes
Trudy Claspill
Community Champion
November 23, 2023

Hello @Jason Hunter 

If you are trying to use curl for this, then you must already have the URL for the Jira instance, correct?

And by "Jira Cloud" you do mean the Software As A Service product hosted by Atlassian, where Atlassian manages all the Jira product updates, correct? You don't mean simply a Jira instance hosted on a system hosted by a cloud-provider like AWS, versus a Jira instance hosted on a physical server managed by a non-cloud-provider, correct?

All Jira Cloud instances are currently in the domain atlassian.net and the URLs are all "https://<somevalues>.atlassian.net". So, just parse the URL to determine if the instance is Jira Cloud or not.

Matthias Gaiser _K15t_
Community Champion
November 23, 2023

@Trudy Claspill, this is true for most of the Jira Cloud instances.

However, there are some exceptions to it. Really old Jira Cloud instances (e.g. k15t.jira.com) can have different urls. I'm not aware of all the variations though.

But more important, there's currently an EAP for custom domains for Jira running - and I expect some time next year, all customers can use them - so more and more different domains for Jira Cloud will pop up with the time.

@Jason Hunter, up to you which method you want to choose.

Like Trudy Claspill likes this
Trudy Claspill
Community Champion
November 24, 2023

Thank you for the correction @Matthias Gaiser _K15t_ !

I knew Atlassian was working on support for custom domains, but had not reviewed recent documentation. I did not realize they had changed the implementation plan to allow something other than atlassian.net. I think originally the an allowed customization of only the sub domain levels.

And I did not know there were older SaaS instances that had different domains.

Even though I'm a community leader, I'm still learning new things from this community. 🤗

Like Matthias Gaiser _K15t_ likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events