1

I'm trying to GET a result via jira REST API using php, but I'm getting unexpected results. When I punch the following URL: http://localhost:8080/rest/api/2/project/ABCD/components directly on the browser I get a result(it works), but when I do it via php I get the following error:

string(76) "{"errorMessages":["No project could be found with key 'RELM'."],"errors":{}}"

the following is the php code:

    $key = trim('RELM');
$ch = curl_init();
$url = "http://localhost:8080/rest/api/2/project/$key/components";
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//  curl_setopt($ch,CURLOPT_HEADER, false);

$output=curl_exec($ch);

curl_close($ch);
var_dump($output) ;
kya
  • 1,798
  • 8
  • 35
  • 61

1 Answers1

1

When you try that url from a browser you've probably logged in in JIRA first, but you don't have any authentication in your php code.

You need to be authenticated to get the correct results. E.g. you can use basic authentication with the credentials of a JIRA user that has permission to browse (or administer, depending on what you want to do) that project.

See also this question.

Community
  • 1
  • 1
GlennV
  • 3,471
  • 4
  • 26
  • 39