无法在“ php-jira-rest-client”中使用身份验证标头

时间:2018-07-12 18:54:52

标签: php curl jira postman jira-rest-api

我想使用Jira REST API生成jira问题。我找到了php-jira-rest-client库,但是认证有问题。通过设置authentication header并将相应的json文件发布到jira服务器,我可以用邮递员成功创建Jira问题。 authentication header是base64编码的(user:password)。我还可以通过使用curl成功地发布并获取REST请求到Jira API:

$ch = curl_init( 'https://jira.somedomain.com/rest/api/2/issue/' ); 
$ticket_json = file_get_contents("/path_to/jira_ticket.json");
curl_setopt( $ch, CURLOPT_POSTFIELDS, $ticket_json );
$headers = array(
    'Content-Type:application/json',
    'Authorization: Basic ---SOME-CREDENTIALS---',
);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
curl_close($ch);

但是当我将相同的凭据与php-jira-rest-client一起使用时,我收到了错误的请求400错误。我不知道为什么这种行为与众不同。

1 个答案:

答案 0 :(得分:1)

您安装了所有要求吗?

要求: PHP JsonMapper phpdotenv