0

As I am new to Rest API's please excuse me, if I ask any silly question.

Below is my script for linking the issues in JIRA via REST API. It is not running properly, could not able to figure out where is the problem as it is not throwing any error also. please help me on this, where I am going wrong.

<?php $restAPIURL = 'http://Company.Name/jira/rest/api/2/'; $projectsURL = $restAPIURL."issueLink/"; function callJIRAAPI($username,$password,$url,$jdata) { $curl = curl_init(); curl_setopt($curl, CURLOPT_USERPWD, "$username:$password"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_POSTFIELDS, $jdata); $issue_list = (curl_exec($curl)); curl_close($curl); return json_decode($issue_list,true);//print_r($arr[0]['issues']); } $data = array( 'type'=>'Relates', 'comment'=>"Testing linkissue Script" ); $data['inwardIssue'][]= array("key"=>"TEST-313"); $data['outwardIssue'][]= array("key"=>"TEST-314"); $jdata = json_encode($data); try { echo $projectList = "<option value='-1'>--List of Links for the project--</option>"; callJIRAAPI($username,$password,$projectsURL,$jdata); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } ?> 
3
  • How is it not running properly what is going wrong? Commented Jul 10, 2015 at 8:28
  • I am not getting any error, to check what is going wrong.And it is not linking the issues as well. Please help. Commented Jul 11, 2015 at 11:21
  • Yes I understand that but what is the error/ thing that happens and what is meant to meant to happen? Commented Jul 13, 2015 at 22:34

1 Answer 1

0

Thank you for your help, I got my answer from the different source.Publishing the answer for ref.The problem is in declaration of the content type.

 function callJIRAAPI($username,$password,$url,$jdata) { $curl = curl_init(); curl_setopt($curl, CURLOPT_USERPWD, "$username:$password"); //curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_POSTFIELDS, $jdata); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($jdata)) ); //print_r(curl_exec($curl)); $issue_list = curl_exec($curl); curl_close($curl); print_r($issue_list); return json_decode($issue_list,true);//print_r($arr[0]['issues']); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.