Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. $new_issue = array(
  2. 'fields' => array(
  3. 'project' => array('key' => "KEY"),
  4. 'summary' => $this->Summary,
  5. 'description' => $this->Description,
  6. 'issuetype' => array('name' => 'Bug')
  7. )
  8. );
  9.  
  10. $body = json_encode($new_issue);
  11.  
  12. self::$handle = curl_init();
  13.  
  14. curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, "POST");
  15. curl_setopt(self::$handle, CURLOPT_POSTFIELDS, $body);
  16. curl_setopt_array(self::$handle, array(
  17. CURLOPT_URL => "jiraUrl//rest/api/2/issue/",
  18. CURLOPT_RETURNTRANSFER => true,
  19. CURLOPT_FOLLOWLOCATION => true,
  20. CURLOPT_MAXREDIRS => 10,
  21. CURLOPT_HTTPHEADER => array("content-type:application/json"),
  22. CURLOPT_HEADER => true,
  23. CURLOPT_SSL_VERIFYPEER => false,
  24. CURLOPT_ENCODING => ''
  25. CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
  26. CURLOPT_USERPWD => $username . ':' . $password
  27. ));
  28.  
  29.  
  30. $response = curl_exec(self::$handle);
  31. $error = curl_error(self::$handle);
  32.  
  33. CURLOPT_URL => "jiraUrl//rest/api/2/issue/
  34.  
  35. CURLOPT_URL => "$jiraUrl//rest/api/2/issue/",
  36.  
  37. $url = "http://your.domain.here/rest/api/latest/issue/"
  38. $username = "username";
  39. $password = "password";
  40. $txt = '{
  41. "fields": {
  42. "project": {
  43. "key": "KEY"
  44. },
  45. "summary": "SUMMARY",
  46. "description": "DESCRIPTION",
  47. "issuetype": {
  48. "name": "ISSUETYPE"
  49. }
  50. }
  51. }';
  52.  
  53. // Create a new cURL resource
  54. $ch = curl_init ();
  55.  
  56. // Set URL and other appropriate options
  57. curl_setopt ( $ch, CURLOPT_URL, $url );
  58. curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
  59. curl_setopt ( $ch, CURLOPT_POSTFIELDS, $txt );
  60. curl_setopt ( $ch, CURLOPT_POST, 1 );
  61. curl_setopt ( $ch, CURLOPT_USERPWD, $username . ":" . $password );
  62.  
  63. $headers = array ();
  64. $headers [] = "Content-Type: application/json";
  65. curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
  66.  
  67. // Grab URL and pass it to the browser
  68. $result = curl_exec ( $ch );
  69.  
  70. echo $result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement