how to create jira issue using restful API with PHP

Abdul June 24, 2022

Greetings, 

I am new with jira restful API, is tehre is any way to create jira issue using https://github.com/lesstif/php-jira-rest-client library, is there is any simple video guide or simple wording article can help me I am stuck with this. 

 

thanks 

Abdul

2 answers

2 accepted

3 votes
Answer accepted
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 24, 2022

The library has an example code on how to create issues here, you should try that out first. Also, the official Atlassian documentation for create issue has a php example. Probably worth checking if you want something basic. I believe the best place to check when it comes to video guide is to search on Youtube. However, API in general has tonnes of videos, which you can look to get a basic understanding of how it works in php then you can use that knowledge and go through the library documentation and script the solution you're seeking.

2 votes
Answer accepted
Customer Portal July 1, 2022

The issue as new user People copy full code from dacomentaion but they don't have that custom fields. So I will suggest you as a starter pass only summary with JSON data

 

Here the start code with help you to connect with this API.

 

require_once 'templates/unirest-php/src/Unirest.php';
//if your on local host add this line
            Unirest\Request::verifyPeer(false);
            Unirest\Request::auth('Email', 'API token');

            $headers = array(
            'Accept' => 'application/json',
            'Content-Type' => 'application/json'
            );
            $body = <<<REQUESTBODY
            {            
            "fields": {
                    "summary": "$title",
                    "issuetype": {
                    "id": "10003"
                    },
                    "project": {
                    "id": "10000"
                    }                  
                }
            }
            REQUESTBODY;
           
           

            $response = Unirest\Request::post(
            'youtrlink/rest/api/3/issue',
            $headers,
            $body
            );
            var_dump($response);
Abdul Qadir July 1, 2022

Thanks, it's really helpful. 

Like Abdul likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events