I'm trying to interact with a WS. This WS accept post requests in multipart and also in x-www-urlencoded. The WS is an OCR service, you send a passport picture and the WS returns a json with the MRZ data.
When I try the WS with postman always works, I send any photo of any size (I tested with 5Mb photo) and always works. When I send the exactly the same data using Curl or Guzzle, if the photo is about 30-50Kb the WS works as expected, but when I send a larger image, for example 500Kb, then the WS doesn't work.
I can access to the Ws code because it's propietary. I just trying to understand why is this happen. This is the multipart function
$url='http://10.0.20.113:8080/';
$req = new Client(['verify' => 0]);
$response = $req->post(
$url, [
'headers' => [
'accept-encoding' => 'gzip, deflate, br',
'accept' => '*/*'
],
'multipart' => [
[
'name' => 'user',
'contents' => 'admin'
],
[
'name' => 'pwd',
'contents' => 'admin'
],
[
'name' => 'doctype',
'contents' => '0'
],
[
'name' => 'new',
'contents' => '1'
],
[
'name' => 'pressmode',
'contents' => '2'
],
[
'name' => 'image1',
'contents' => $img1
],
[
'name' => 'image2',
'contents' => $img2,
]
],
]
);
Log::info('Response received');
return $response->getBody()->getContents();
this is another try with curl
$ch = curl_init();
$headers = array();
$post = array('user' => 'admin', 'pwd' => 'admin', 'doctype' => 0, 'new' => 1, 'pressmode' => 2, 'image1' => $img1, 'image2' => $img2); // e.g. $fieldName = 'image'
curl_setopt_array(
$ch,
[
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $post,
CURLOPT_SSL_VERIFYPEER => 0
]
);
$result = curl_exec($ch);
$response = curl_getinfo($ch);