繁体   English   中英

使用 Rest API 列出 JIRA 项目

[英]Listing JIRA Projects with Rest API

我试图列出 JIRA 中的项目,我确实找到了一段代码,但目前它什么也没返回。

有没有一种简单的方法可以使用 php 和 JIRA rest api 列出项目?

我知道这是来自另一篇文章的代码片段,但我确实得到了该片段不返回错误的程度。

$response = file_get_contents("http://localhost:8082/rest/api/latest/project?expand&username=$username&password=$password");

使用基本身份验证访问API时,用户名和密码不应是GET参数。

有关在PHP中通过cURL使用基本身份验证的说明,请参见此答案

如果您不使用HTTPS,则应考虑使用o Auth身份验证方法,而不是基本身份验证。

<?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";
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM