I'm trying to send some form fields along with multiple files using CURL in php, got the below error.
"Required Multipartfile parameter utterance is not present".
Below listed is the piece of code, I have used in my application.
$a1614_1 = "@" .realpath("RecordFiles/1614_1.wav");
$payload = array("sessionid"=>$sessionid,"clientid"=> $clientid,"userid"=>$userid,"utterance"=> $a1614_1,"type"=>$type,"action"=>$action);
$multipart_boundary = "ABC1234";
$request_headers = array();
$request_headers[] = "Content-Type: multipart/form-data; boundary=". $multipart_boundary;
$curl_options = array(
CURLOPT_URL => $base_api_url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query( $payload),
CURLOPT_HTTP_VERSION => 1.0,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true,
CURLOPT_HTTPHEADER => $request_headers
);
$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );
curl_close ($curl);
In my code i'm passing utterance as one of the multipart parameter but still i'm getting the same error. I have googled to resolve the problem but not able to fix it. Is there any problem in the above code approach, if any one have idea please share to me to fix or resolve the issue.
Please help / assist me to resolve this issue.