配列をCURLOPT_POSTFIELDSに渡すと、URLエンコードが自動的に行われると言われていますが、何らかの理由でそれが行われていません。私は自分で文字列をエンコードしようとしましたが、それはヘッダーを取りません。配列を渡すと、エンコードされません。
これが私のコードです:
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json', 'Content-Type: application/x-www-form-urlencoded"));
curl_setopt($ch, CURLOPT_URL, "http://localhost:8888/testrail/index.php?/miniapi/add_case/s2");
curl_setopt($ch, CURLOPT_POSTFIELDS, $caseArgs);//$caseArgs is an array from another function
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_exec($ch);
編集 - - -
Here is the array that I am working with:
/*Function to set the data for each individual test case*/
function setTestCase($cellValue){
$case[]=array();
$case['title'] = $cellValue[0];
echo $case['title']. "<- Title"."<br/>";
$case['type'] = $cellValue[1];
echo $case['type']. "<- Type"."<br/>";
$case['priority'] = $cellValue[2];
echo $case['priority']. "<- Priority"."<br/>";
/*$case['estimate'] = $cellValue[3];
echo $case['estimate']. "<- Estimate"."<br/>";
$case['milestone'] = $cellValue[4];
echo $case['milestone']. "<- MileStone"."<br/>";
$case['refs'] = $cellValue[5];
echo $case['refs']. "<- Custom Refs"."<br/>";
$case['precon'] = $cellValue[6];
echo $case['precon']. "<- Custom Precondition"."<br/>";
$case['steps'] = $cellValue[7];
echo $case['steps']. "<- Custom Steps"."<br/>";
$case['expectedresults'] = $cellValue[8];
echo $case['expectedresults']. "<- Expected Results"."<br/>";
$case['testSuite'] = $cellValue[9];
echo $case['testSuite']. "<- TestSuite"."<br/>";*/
$caseData=array(
'Title'=> $case['title'],
'Type'=> $case['type'],
'Priority'=> $case['priority'],
'key'=> "246810",
);
return $caseData;
}