11 Replies Latest reply on May 10, 2017 12:51 PM by kdoronzio

    FileMaker 16 Rest API


      So far I've managed to successfully connect to FMS16 using cURL in the Terminal; I've used Paw to perform all CRUD operations and I've successfully connected a client FM16 database to a hosted database and also managed all CRUD operations, but ...


      I've had no success using cURL in PHP to connect to a FMS hosted database. I've tried with a Debian-hosted PHP script running in a VMWare virtual machine and I've also tried a localhost PHP script on my Mac. On both instances, FMS16 is installed on a VMware virtual machine running OS X 10.12.4. I'm using PHP 5.6.30 in all set-ups. I've also tried it with FileMaker Server's own baked in PHP and my own standard installation on Sierra. Neither would make a connection to the FMS hosted database.


      Has anyone else tried this?


      The trouble seems to start with initializing a cURL session using $ch = curl_init(). This causes the script to bomb totally. Has anyone come across this?


      This is an example of the PHP script that I've been using:



      $data = array("user" => "restuser", "password" => "restpass", "layout" => "contacts" );                                                                                                                                     

      $data_string = json_encode($data);

      echo $data_string."<BR>"; // this checks to see if the json is OK. Useful for debugging


      $ch = curl_init();

      curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 

      curl_setopt($ch, CURLOPT_URL, 'https://fms16.local/fmi/rest/api/auth/contacts');   // also tried http:// with no luck too                                                                 

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

      $result = curl_exec($ch);


      return $result;