While trying to get Search Results from Jira I get the following error message (while curl does not report any error):
HTTP/2 401 server: nginx date: Tue, 18 Jun 2019 12:49:55 GMT content-type: text/html;charset=UTF-8 x-arequestid: 895x15999953x1 x-xss-protection: 1; mode=block x-content-type-options: nosniff x-frame-options: SAMEORIGIN content-security-policy: frame-ancestors 'self' x-asen: SEN-8414684 x-seraph-loginreason: AUTHENTICATED_FAILED www-authenticate: OAuth realm="https%3A%2F%2FOURSERVER.com"
Encountered a "401 - Unauthorized"
error while loading this page.
Basic Authentication Failure - Reason : AUTHENTICATED_FAILED
Here is my PHP (v.7.3 on IIS) code:
<?php
$restUser = 'XXX';
$restPass = 'YYY';
$restSearch = 'jql=filter=12789';
$restMax = 10;
$restGET ="https://OURSERVER/rest/api/2/search?$restSearch&maxResults=$restMax";
$connMsg = "Verbindung zu Jira REST Api via curl ";
$connObject = false;
$connInfo = '';
$connCtr = 0;
$connJson = '';
$connResult = '';
// lets go:
$connHeader = array();
$connHeader[] = "Authorization: Basic ".base64_encode($restUser.":".$restPass);
$connHeader[] = "Content-Type: application/json";
$conn = curl_init();
curl_setopt($conn,CURLOPT_URL,$restGET);
curl_setopt($conn,CURLOPT_RETURNTRANSFER,1);
curl_setopt($conn,CURLOPT_HEADER,true);
curl_setopt($conn,CURLOPT_HTTPHEADER,$connHeader);
curl_setopt($conn,CURLOPT_CAINFO,'C:\...\cert\cacert.pem'); // from: https://curl.haxx.se/ca/cacert.pem
// curl_setopt($conn,CURLOPT_SSL_VERIFYPEER,false); // disable SSL Verification (dirty)
$connJson = curl_exec($conn);
if(!curl_errno($conn)){
$connInfo = curl_getinfo($conn);
$connMsg .= "ok, Zeichenanzahl = ".strlen($connJson).' ('.$connInfo['total_time'].' Sek.)';
$connMsg .= '<br>Abfrageergebnis: ';
$connResult = $connJson;
} else {
$connMsg .= 'FEHLER:<br>'.curl_error($conn);
}
curl_close($conn);
?>
<html>
<body>
<h1>Jira REST Testseite (curl)</h1>
<h2><?php echo $connMsg;?></h2>
<p><?php echo $connResult;?></p>
</body>
</html>
Same works fine when I do a PHP file_get_contents and include Username and Password in the Url. Also it ist 100% sure that the sent credentials are valid.
What does the errormessage mean:
Is the Authentification Method not allowed on the server?
Thanks for any help!
Hi,
It seems that the issue relates to the same as https://community.atlassian.com/t5/Questions/JIRA-Rest-API-authentication-always-returns-401-unauthorized/qaq-p/1110047.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.