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

JIRA REST api in PHP

Rachel Smith March 21, 2013

Hi,

I'm new in using jira rest api.

Here is my code:

$username = 'xxxx';

$password = 'xxxx';

$url = 'http://1.2.3.4:8080/rest/api/2/Issue/DEMO-7';

$curl = curl_init();

curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");

curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);

$issue_list = (curl_exec($curl));

echo $issue_list;

Why am I getting this error?:

Encountered a 401 - Unauthorized error while loading this page.

How to deal with this? Is there anything I need to configure in JIRA or in my Server?

If you have simpliest approach in calling rest api I will be glad to know it.


2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted
Aleksander Mierzwicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2013

It looks like you've entered wrong credencials. This code works fine, after changing "Issue" to "issue" in URL.

I've got 401 when username/password was incorrect.

The other thing may be that your user is locked and you need to solve captcha - try to login with that credentials to JIRA via web interface.

Hope that I could help,
Alek.

Rachel Smith April 7, 2013

Thanks Aleks

0 votes
Cid Elu October 23, 2013

Hi, this same thing happens to us. When we connect via curl, the account is eventually being locked. Is there a way to avoid that? We can't always log in on the web interface just to solve the captcha.

TAGS
AUG Leaders

Atlassian Community Events