Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="wrapper">
- <h1>Create Issue</h1>
- <form id="create-form">
- Summary: <input type="text" name="summary" id="summary" value=""/>
- Description: <input type="text" name="description" id="description" value="" />
- Issue Type: <input type="text" name="type" id="type" value=""/>
- Username: <input type="text" name="user" id="user" value=""/>
- Password: <input type="password" name="pass" id="pass" value=""/>
- <input type="button" id="button" value="Create Issue"/>
- </form>
- </div>
- <script>
- $('#button').click(function() {
- $.ajax({
- type: "POST",
- url: "jiraapi.php",
- data: $('#create-form').serialize(),
- success: function(data){
- alert(data);
- },
- dataType: "html"
- });
- });
- </script>
- <?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;
- ?>
Add Comment
Please, Sign In to add comment