0

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.

1

1 Answer 1

2

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',
   )
));
Sign up to request clarification or add additional context in comments.

3 Comments

I dont see in their examples where they set username or password... kinda unsure how it connects. github.com/lesstif/php-jira-rest-client/blob/master/tests/… and the function testCreateIssue() is what im looking for, but again don't see a way to authenticate or connect to Jira.
On the first page is an example... github.com/lesstif/php-jira-rest-client
Okay im just blind. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.