我想使用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错误。我不知道为什么这种行为与众不同。
答案 0 :(得分:1)
您安装了所有要求吗?
要求: PHP JsonMapper phpdotenv