Skip to content

Instantly share code, notes, and snippets.

@theredstapler
Created November 4, 2016 16:26
Show Gist options
  • Save theredstapler/898ddec18117d0ce16fca7edba2dfca1 to your computer and use it in GitHub Desktop.
Save theredstapler/898ddec18117d0ce16fca7edba2dfca1 to your computer and use it in GitHub Desktop.
<?php
$base64_usrpwd = base64_encode($_POST['user'].':'.$_POST['pass']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8080/rest/api/2/issue/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '.$base64_usrpwd));
$arr['project'] = array( 'key' => 'TP');
$arr['summary'] = $_POST['summary'];
$arr['description'] = $_POST['description'];
$arr['issuetype'] = array( 'name' => $_POST['type']);
$json_arr['fields'] = $arr;
$json_string = json_encode ($json_arr);
curl_setopt($ch, CURLOPT_POSTFIELDS,$json_string);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment