PHP example needed - Report Exporter

HELP - Report Exporter
I having tried many variations and cannot get past the "No Template Submitted" error.
I have figured out how to submit the requestJobDescription portion, but do not know how to add the report template. I created a template file, but how do I duplicate the "--data-urlencode" step in the code below?
=-----------------------------------------------------------------------------------=
// Global for Expensify
$url="https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations";
$partnerUserID = "...";
$partnerUserSecret ="...";
$emailid = "...";
// template file
$template_report = "template_report_export.ftl";
$send_template = fopen($template_report, "r");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, "requestJobDescription={
\"type\":\"file\",
\"credentials\":{
\"partnerUserID\": \"$partnerUserID\",
\"partnerUserSecret\": \"$partnerUserSecret\"
},
\"onReceive\" : {
\"immediateResponse\" : \"returnRandomFileName\"
},
\"inputSettings\":{ \"type\":\"combinedReportData\", \"reportState\": \"APPROVED\", \"filters\":{ \"approvedAfter\":\"2018-07-01\" }, \"outputSettings\":{ \"fileExtension\":\"csv\" } } }
");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_INFILE, $send_template);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($template_report));
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
Answers
-
Sheena Trepanier Expensify Team, Approved! Accountant, Expensify Student Ambassador Posts: 1,362 Expensify Team
Hello @InnovAsian, thanks for sharing this. I'm sorry I don't have an answer for you now, but I've reached out to my team for a little extra technical help on this one. As soon as I possibly can I'll be back to you on this thread with more information.
-
A helpful hint to all those reading your API document: If you are using CURL on a Unix style system, the Curl example syntax is valid. If you are using a Windows system, enclose you -d statement with double-quote and use single (or no) quotes within.