0

I am trying to list projects that are in JIRA and I did find a snippet of code but currently it is returning nothing.

Is there a simple way to list projects using php and the JIRA rest api?

I know this this is snippet of code from a different post, but I did get the snippet to the point of not returning an error.

$response = file_get_contents("http://localhost:8082/rest/api/latest/project?expand&username=$username&password=$password");
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
bama
  • 119
  • 1
  • 8

2 Answers2

0

When using Basic Auth to access the API, the username and password should not be GET parameters.

See this answer for instructions on using basic auth via cURL in PHP.

If you aren't using HTTPS, you should consider using the oAuth authentation method rather than basic auth.

Community
  • 1
  • 1
Mathew Tinsley
  • 6,805
  • 2
  • 27
  • 37
-1
<?php
$pagecode=   "using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://your-domain.atlassian.com/rest/api/3/project\"))
    {
        request.Headers.TryAddWithoutValidation(\"Accept\", \"application/json\"); 

        var base64authorization = Convert.ToBase64String(Encoding.ASCII.GetBytes(\"email@example.com:<api_token>\"));
        request.Headers.TryAddWithoutValidation(\"Authorization\", $\"Basic {base64authorization}\"); 

        var response = await httpClient.SendAsync(request);
    }
}\n";

echo "$pagecode";
?>
Swati
  • 234
  • 2
  • 10
  • This does not look like PHP code. Also, you should add some explanation to your answer such that others can learn from it – Nico Haase May 07 '21 at 12:27