0 Replies Latest reply: Jan 28, 2018 6:06 PM by Lauri Scharf RSS

    Load external data with API

    Lauri Scharf

      Is it possible to load data into Sense from an external source which has an API? The source system is web-based and uses mySQL. The API sample PHP code looks like this:

       

      <?php

      $data = array(

          'token' => 'asdf098ghqh',

          'content' => 'record',

          'format' => 'csv',

          'type' => 'flat',

          'fields' => array('abstractor_1','bmi_data_1'),

          'rawOrLabel' => 'raw',

          'rawOrLabelHeaders' => 'raw',

          'exportCheckboxLabel' => 'false',

          'exportSurveyFields' => 'false',

          'exportDataAccessGroups' => 'true',

          'returnFormat' => 'json'

      );

      $ch = curl_init();

      curl_setopt($ch, CURLOPT_URL, 'https://myurl.com/redcap/api/');

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

      curl_setopt($ch, CURLOPT_VERBOSE, 0);

      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

      curl_setopt($ch, CURLOPT_AUTOREFERER, true);

      curl_setopt($ch, CURLOPT_MAXREDIRS, 10);

      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

      curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);

      curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));

      $output = curl_exec($ch);

      print $output;

      curl_close($ch);

       

      Can I run or invoke this from Sense Enterprise? The API also allows for Java, cURL, Ruby, Perl, Python and R.

       

      Thanks in advance.