API Report Exporter always creates two export files with different filenames and same contents.

When I request all my Approved reports after a certain date to be uploaded to my FTP site, it creates two files with different names and same contents. I can work around the issue, but it is strange.
The InputSettings "type" parameter is set to the only valid choice, 'combinedReportData', so I am not sure why it occurs.
------- PHP code snippet --------
$ch = curl_init();
$headers=array('Content-Type: multipart/form-data');
$post_fields=array();
$file_name_with_full_path="template_report_export.ftl";
$requestJobDescription["type"]="file";
$requestJobDescription["credentials"]=array(
"partnerUserID"=>$partnerUserID,
"partnerUserSecret"=>$partnerUserSecret
);
$requestJobDescription["onReceive"]=array("immediateResponse"=> array("returnRandomFileName"));
$requestJobDescription["inputSettings"]=array(
"type"=>"combinedReportData",
"reportState"=>"REIMBURSED",
"limit"=>"99",
"filters"=>array(
"approvedAfter"=>"2018-10-01" ,
"startDate"=>"2016-01-01",
"markedAsExported"=>"Expensify Export"
)
);
$requestJobDescription["outputSettings"]=array("fileExtension"=>"csv");
$requestJobDescription["onFinish"]=array(
array("actionName"=>'sftpUpload',
"sftpData"=>array(
"host"=>"anything.com",
"login"=>"username",
"password"=>"password",
"port"=>22
)
)
);
$post_fields['requestJobDescription']=json_encode($requestJobDescription);
$post_fields['template'] = file_get_contents($file_name_with_full_path);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
$result = curl_exec($ch);
$response= curl_exec($ch);
$info= curl_getinfo($ch);
echo "Request not successful. Response code : ".$info['http_code']."
";
echo "Response : $response";
curl_close ($ch);
------- PHP code snippet --------
Answers
-
Hi there,
Thanks for posting here. After a quick look at your code snippet, it looks like you're calling
curl_exec($ch)
twice, which causes two requests to be sent to our servers, and thus two files being uploaded to your SFTP server:$result = curl_exec($ch); $response= curl_exec($ch);
Simply remove one of those lines and it should resolve your issue.
Cheers -
oops