Hi guys, I have been trying to get the base url of jira through rest api by passing credentials, but unable to do it. please help...
Little late to the party, but as this is not answered still after 2 years, I'll try to help.
Once you have oauth access token of the user, you can make a get call on
https://api.atlassian.com/oauth/token/accessible-resources with token.
This will give a list of all the sites accessible to the user along with it's cloudIds and siteUrls.
More info here: https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/
As already mentioned in the other replies, in order to call a REST API endpoint you must already know the base url.
Also, id.atlassian.com is mainly used for Single Sign On. This means that if you have multiple JIRA instances, after you log into id.atlassian.com, you can access all your JIRA instances without having to log-into all of them one by one.
Still, after being authenticated into id.atlassian.com, you need to know which one your JIRA instances are in order to access them. :)
I hope this helps clarifying.
Atlassian Cloud Support
I know this is an old thread but I stumbled on it looking for the same answer as Mohammed and this thread is not answered. Maybe phrased in a different way it can lead to an answer.
I am building a plugin that will hopefully have many users. When making calls to the rest API should I always be using my-domain (hard coded into my plugin) or should I be using a domain that is relevant/applicable to my user/s?
If its the latter then there needs to be a way to lookup the domain of my user and dynamically use it as the base-url to make API calls.
I did a bit more searching and found this:
Requests that use OAuth 2.0 (3LO) are made via
https://your-domain.atlassian.net). Construct your request URL using the following structure:
Since I am using OAuth 2 this means I need to change my request URL anyway.
Hi @RodPienaar ,
Welcome to the Atlassian Community.
I believe you have already found the answer by yourself, however, please confirm this is the case.
Also, for the future, please notice that this is not the best place to get help on development related questions. The right resources are listed in https://developer.atlassian.com/resources.
I'm afraid your requirement is nonsense.
If you don't know the base url, then you can't go to it to ask it where it is.
Imagine a real-world example. You know you want to get a telephone number for someone. What you're asking is to be able to ring them up to get it. But you don't have their number so you can't.
You need to re-think what you are doing here. You MUST give it a base url somehow, if you want to connect to it.
Server and Cloud platforms work differently in this regard. All the Jira Cloud instances are forcing users to go through he ID site as means to authentication, but Jira Server has no such requirement. For Jira Server, the Jira site itself is handling authentication, unless you are using some other SSO solution like Crowd, Okta, etc.
Could you provide us more information about what you are trying to accomplish here? Are you trying to create a plugin for Jira Cloud or for Jira Server?
The rest endpoint I cited was actually for Jira Server. If you were using Jira server it is possible that you could be connecting to that Jira instance on some other address that is not the baseurl (such as an IP, a simple hostname, or localhost if access directly). In cases like that, then you can still make a rest call to that address in order to find out what the base url value has been set to in that instance.
Hence when you mentioned base URL, I think both Nic and myself believed you were referring to Jira Server. Since in Jira Cloud, you cannot set the base URL, it is hard coded based on the domain name you selected when first setting up that site.
Ok, just to clarify where I am coming from. Yes, you go to id.atlassian.com/login and that logs you in to your Atlassian account.
Now, I have access to a number of Atlassian and Cloud systems. Once logged in to my Atlassian account, I've got a token that will let me in to them.
Now, tell me how I get to Jira 1, Jira 2 or Jira 3?
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