Hi, i try to get the rest api responses with Curl in php, but i can't authenticate...
$username = '****'; $password = '****'; $url = 'https://****.onjira.com/rest/api/2.0.alpha1/issue/COU-1432?expand=changelog'; $userAgent = 'Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0'; $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, $userAgent); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 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); print_r(curl_exec($curl));
It always return me: {"errorMessages":["Vous n'avez pas l'autorisation de voir la demande indiquée","Connexion requise"],"errors":{}}
How can i get the json code in this url?
Thank you for your help
Community moderators have prevented the ability to post new answers.
I've got a slightly simpler version working nicely:
<?php $json = `curl -u username:password https://jira.atlassian.com/rest/api/latest/issue/JRA-9.json`; echo $json;
See also: The Simplest Possible JIRA REST Examples
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.