I am sending a HTTP request via cURL and I keep getting this 413 error. The file that I am trying to send is on 21kb and I have checked my php.ini file. Can someone tell me what is wrong?
Here is my code that is directly effecting the HTTP request:
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Class for creating test cases to be sent
* into TestRail
* @author Banderson
*/
class testCase {
/*Function to get the data for each individual test case*/
function getTestCase($row, $highestColIndex, $PHPobjWorksheet){
echo "<br />";
for($col=0;$col<=$highestColIndex;++$col){
$v=$PHPobjWorksheet->getCellByColumnAndRow($col,$row)->getValue();
$cellValue[]=$v;
}
return $cellValue;
}
/*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;
}
function sendTestCase($caseArgs){
try{
$ch = curl_init();
//$sendData = http_build_query($caseArgs);
$header=array();
$header[]= "Accept: application/json";
$header[]= "Host: localhost";
$header[]= "Title=newTitle";
$header[]= "key=2467810";
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8888/testrail/index.php?/miniapi/add_case/2');
curl_setopt($ch, CURLOPT_POSTFIELDS, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
}
catch (HttpException $ex){
echo $ex."<-Exception";
}
}
}
?>
I would have included my php.ini file, but that is too big. I’m open to any advice! Thank you in advance!
413 is ‘request entity is too large’. Any reason you’re trying to stuff HTTP headers into the POSTFIELDS section? If this service is not expecting any post fields (eg. body should be 0 bytes), then using POSTFIELDs to send your “headers” will definitely set this off. For headeres, you should be using
CURLOPT_HTTPHEADERinstead