Reputation: 2216
I have recently started working with Jira and am trying to make a web based form on my customer client portal that will allow people to enter issues.
From my searching I have found the API examples Jira provides: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue
However this uses something alone these lines:
curl -D- -u fred:fred -X POST --data {see below} -H
"Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
However curl is something I have never used before. I have it configured in on my server to work (did a basic test to ensure it does). But I feel like this setup is not how it works for PHP.
Online I find it says to break the curl into parts like this:
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_URL, $url);
but I am very unsure how I would break that command into it... also unsure how I would receive the data it is supposed to return (From the sites example):
{
"id":"39002",
"key":"TEST-103",
"self":"http://localhost:8090/rest/api/2/issue/TEST-103"
}
Any tips for going about creating an issue in PHP like this would be fantastic.
Upvotes: 0
Views: 4100
Reputation: 27295
There are good SDKs to work with:
https://github.com/chobie/jira-api-restclient
https://github.com/lesstif/php-jira-rest-client
Then you have a lot of function and a clean structure to work with JIRA. The second one has more function.
Login example:
use JiraRestApi\Configuration\ArrayConfiguration; use JiraRestApi\Issue\IssueService;
$iss = new IssueService(new ArrayConfiguration(
array(
'jiraHost' => 'https://your-jira.host.com',
'jiraUser' => 'jira-username',
'jiraPassword' => 'jira-password',
)
));
Upvotes: 2