zendserver 2019.7 php 7.3 apache 2.4
In the test environment, I am sending JSON post requests through curl to my local server. When the CURLOPT_POSTFIELDS is less than e.g 1000 characters its scripts are executed and I am getting responses fine.
But the same script when I am increasing the length of the JSON array then I am getting a 404 error.
I have changed all the configurations like post_max_size etc but nothing working.
$json_data = '{
"Recon": [
{
"ItemNumber": "96",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "97",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "98",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "99",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "100",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "101",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "102",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "103",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "104",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "105",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "106",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "107",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
},
{
"ItemNumber": "108",
"StorageLocation": "L1",
"Quantity": "2060.800",
"UOM": "KG"
}
]
}';
$url = 'http://ipaddress/projectname/recon.php';
$ch = curl_init($url);curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
CodePudding user response:
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
you try to send a string.
php manuals says:
CURLOPT_POSTFIELDS
The full data to post in a HTTP "POST" operation. This parameter can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with the field name as key and field data as value.
try this, your string as array with key named myjson:
curl_setopt($ch, CURLOPT_POSTFIELDS, ['myjson'=>$json_data]);
CodePudding user response:
Thanks all for support and finally i track there was a firewall restriction which Network team resolve and it now working fine. Thanks again
