Automating Data Loads with cURL Follow

Hāpara allows the automation of data loads by uploading Class and Student data through standard HTTP requests. Doing so involves extracting data from your Student Information System, and pushing a CSV file to Hāpara via a URL request tool, such as cURL.

To implement this process, the following steps are required (we recommend reaching out to your IT or Tech support team to query this further):

  1. Create an automated data export from your Student Information System to a CSV file in a local directory. This CSV file should be formatted to contain the same fields required if you were uploading data through a Google Spreadsheet. Templates can be created and downloaded via the Manual Configuration page.
  2. Create a CRON job (Unix) or Scheduled Task (Windows) containing the URL request specified below.

Once you have set up the above two steps, you can use cURL or another URL request tool to upload the CSV file to Hāpara. Here is an example cURL to upload CSV files to Hāpara:

curl -F "passkey=<PASS_KEY>" -F "uploadFile=@<PATH_TO_YOUR_CSV_FILE>" https://td-setup.appspot.com/<DOMAIN_NAME>/csvupload


The mandatory parameters of this request are:

  • passkey: A pass key used to authenticate against the domain for which the CSV file is uploaded. This pass key can be found at https://settings.teacherdashboard.com/#/d/studentdomain/loader/url-load. If the pass key is not correct, then the uploaded CSV file will not be processed.
  • uploadFile: The CSV file object to be uploaded. The location of the file must be prefixed with @. This instructs cURL to construct an HTTP Request containing the file.

The optional parameters of this request are:

  • loadAll: If this parameter is set to "True" (or any non-null value), then the load will process all records specified in the CSV file. If it is not specified, the load will only process records which it detects have changed from the previous load.
  • multipleYears: If this parameter is set to "Y", then the load will process all classes specified in the CSV file regardless of year. If it is not specified, then the load will only process classes that are in the same year as existing classes.
  • email: If this parameter is set to an email address then all email notifications for this load will be sent to the specified email. If it is not specified then the load will send any emails to the Primary Contact.
     

For those using PHP, a suggested format of the PHP command is below:

$target_url = 'https://td-setup.appspot.com/<DOMAIN_NAME>/csvupload';
$post = array(
   'passkey' => '<PASS KEY>',
   'uploadFile' => '@<PATH_TO_YOUR_CSV_FILE>');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch); 

If your CSV is larger than 5MB, then we recommend building your URL request in this format:

Linux/MacOS users:

curl -F "passkey=<PASS_KEY>"  https://td-setup.appspot.com/<DOMAIN_NAME>/createuploadurl | xargs curl -X POST --header "Transfer-Encoding: chunked" -F "file=@<PATH_TO_YOUR_CSV_FILE>"


Windows users can create a batch file to run the following:
Note: tmpFile is a path you're setting for a temporary file to be created by this process.

curl -F "passkey=<PASS_KEY>" https://td-setup.appspot.com/<DOMAIN_NAME>/createuploadurl > tmpFile
set /p myvar= < tmpFile
curl -X POST --header "Transfer-Encoding: chunked" -F "file=@<PATH_TO_YOUR_CSV_FILE>" %myvar%
del tmpFile
 
Additional Resources:
Have more questions? Submit a request