We seem to be unable to connect to the JIRA REST API at our JIRA server.
I tried both using cURL via PHP with Basic authentication and via file_get_context with a stream context to provide authentication within a HTTP header.
In all situations I was unable to receive any data. I've also tried user-posted examples that they claim work, which also return a HTTP 401 unautorized response in my case (yes, I triple checked username/password).
That makes me think, are there any special users or user requirements for using the API. Or does the API need to be activated somehow?
Regards,
Document Ready
Community moderators have prevented the ability to post new answers.
Are remote calls enabled in Admin -> General config?
The REST interface will expose things with the same rights as a "real" user, so you do need to log in as someone who has access to the issues you are trying to work with.
If you meet those two criteria, then you should be able to get through, there's nothing else you need to do.
Yes, "Accept remote API calls" is set to "ON" and I use the main admin who has access to the entire JIRA environment. Warning: file_get_contents(https://[SERVER].atlassian.net/rest/api/2/browse/DREADY-11): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized (using same url as user in browser using file_get_contents with Authorization header) Warning: file_get_contents(https://[SERVER].atlassian.net/rest/api/2/issue/DREADY-11): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized (fetched from examples and/or other users using file_get_contents with Authorization header) Encountered a "401 - Unauthorized" error while loading this page. Go to JIRA home (using cURL with USERPWD on either url's)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you running JIRA behind a web-server like Apache?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are running JIRA in the Atlassian cloud, not sure we can/want to tinker with that...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, ok, then REST is correctly configured. You'll be getting the 401 because your authorisation is failing - you've got the right username and password, so it must be something in your code not reusing the authorisation that has been established.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Max,
I'm not sure how we solved this but it's working now. We use an administrator login and the following cUrl request:
$url = 'https://xxxxx.atlassian.net/rest/api/2/search?jql=order+by+updated+DESC&expand=names&startAt=0&maxResults=5000'; $curl = curl_init(); curl_setopt($curl, CURLOPT_USERPWD, $sUsername.":".$sPassword); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); $sIssues = curl_exec($curl);
That works for us.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you solve the problem, as I have the same issue; using cloud, using a username (not email) and correct password and using basic auth through Postman or cUrl, but same results, a 401 and lot of garbage html send back to me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you provide an exmaple of a JIRA rest api that you are trying to hit?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.