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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

JIRA REST api in PHP

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

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.

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
Community showcase
Posted in Europe

RSVP: Warten auf das Christkind (Virtual International Edition)

    There are a lot of holidays between November  and January every year (too many to list here, see https://en.wikipedia.org/wiki/Lists_of_holidays) and for most ...

17 views 0 0
View post

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