I have API backend that accepts base64 of PDF and parses it. The API works in postman. The HTTP request as below, that works well:
POST /convert HTTP/1.1
Host: 1.1.1.1:7000
Content-Type: application/x-www-form-urlencoded
data=JVBERi0xLjMKJcTl8uXrp/Og0MTGCjQgMCBvYmoKPDwgL0xlbmd0aCA1IDAgUiAvRmlsdGVyIC9GbGF0ZURlY29kZSA+Pg...SHORTENED FOR READABILITY....MDE3OTg1TMxMTNiYjAyNWI0NWRmZDhkZmE+IF0gPj4Kc3RhcnR4cmVmCjE4NDkxMwolJUVPRgo=
However, when the same is done via PHP as below, it returns 500 error.:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://1.1.1.1:7000/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "data=JVBERi0xLjM...4Kc3RhcnR4cmVmCjE4NDkxMwolJUVPRgo%3D",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
Curl from the terminal executed via shell script throws argument list too long error. What could be possibly wrong?