Skip to content

Instantly share code, notes, and snippets.

@asimpkin
Last active November 6, 2019 00:45
Show Gist options
  • Save asimpkin/5ba4b99fafc2e6296e2a0477a538a465 to your computer and use it in GitHub Desktop.
Save asimpkin/5ba4b99fafc2e6296e2a0477a538a465 to your computer and use it in GitHub Desktop.
jira_curl_post_test
<?php
DEFINE("USER","USERNAME");
DEFINE("PASS","PASSWORD");
DEFINE("INSTANCE","INSTANCE");
//$URL = 'https://jira.URL.com/jira/rest/api/2/issue/createmeta';
$URL = 'https://jira.URL.com/jira/rest/api/2/issue/';
/*
$query=urlencode($query);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, USER .':'. PASS);
$data = curl_exec($ch);
curl_close($ch);
*/
$description = "Hello World";
$project_id = '10141'; // ANGELTEST
$data_string = '{"fields":{"project":{"id":"'.$project_id.'"},"summary":"TEST AJ Simpkin :: '.date(Ymdhms).'","description":"'.$description.'","customfield_10183":"0b94ec56dce30000417720bc230898ea","customfield_10184":"https://'.INSTANCE.'.service-now.com/nav_to.do?uri=task.do?sys_id=0b94ec56dce30000417720bc230898ea","customfield_10660":"INC000001","customfield_10057":{"id":"10042"},"issuetype":{"id":"1"}}}}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
//echo"<pre>";
print_r($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment