Hello everyone,
I'm new to Jira REST API so I have a Jira running on localhost, just to get used to it. Right now I'm just tryring to authenticate. The problem ist, that I get a 403. This is my code:
$username = 'username';
$password = 'api token';
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://localhost:8080/rest/api/2/user?username=username');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$query = curl_exec($curl_handle);
curl_close($curl_handle);
echo $query;
@kardondo you want to use api tokens with Jira Server? Api tokens are only for Jira Cloud.
You can check more here: https://developer.atlassian.com/server/jira/platform/security-overview/
$ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => JIRA_URL . '/rest/api/2/user?username=' . $USER, CURLOPT_USERPWD => $USERNAME . ':' . $PASSWORD,
CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_RETURNTRANSFER => true ));
$result = curl_exec($ch); curl_close($ch); echo json_decode($result);
Can you above code a trial? If this works, and are you admin on your instance, i.e. have permission to read users information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.