Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $new_issue = array(
- 'fields' => array(
- 'project' => array('key' => "KEY"),
- 'summary' => $this->Summary,
- 'description' => $this->Description,
- 'issuetype' => array('name' => 'Bug')
- )
- );
- $body = json_encode($new_issue);
- self::$handle = curl_init();
- curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt(self::$handle, CURLOPT_POSTFIELDS, $body);
- curl_setopt_array(self::$handle, array(
- CURLOPT_URL => "jiraUrl//rest/api/2/issue/",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_HTTPHEADER => array("content-type:application/json"),
- CURLOPT_HEADER => true,
- CURLOPT_SSL_VERIFYPEER => false,
- CURLOPT_ENCODING => ''
- CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
- CURLOPT_USERPWD => $username . ':' . $password
- ));
- $response = curl_exec(self::$handle);
- $error = curl_error(self::$handle);
- CURLOPT_URL => "jiraUrl//rest/api/2/issue/
- CURLOPT_URL => "$jiraUrl//rest/api/2/issue/",
- $url = "http://your.domain.here/rest/api/latest/issue/"
- $username = "username";
- $password = "password";
- $txt = '{
- "fields": {
- "project": {
- "key": "KEY"
- },
- "summary": "SUMMARY",
- "description": "DESCRIPTION",
- "issuetype": {
- "name": "ISSUETYPE"
- }
- }
- }';
- // Create a new cURL resource
- $ch = curl_init ();
- // Set URL and other appropriate options
- curl_setopt ( $ch, CURLOPT_URL, $url );
- curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
- curl_setopt ( $ch, CURLOPT_POSTFIELDS, $txt );
- curl_setopt ( $ch, CURLOPT_POST, 1 );
- curl_setopt ( $ch, CURLOPT_USERPWD, $username . ":" . $password );
- $headers = array ();
- $headers [] = "Content-Type: application/json";
- curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
- // Grab URL and pass it to the browser
- $result = curl_exec ( $ch );
- echo $result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement