1 Reply Latest reply on Apr 30, 2014 11:46 AM by azriley

    Communication Error: (22) The requested URL returned error: 401 - This can be due to an invalid...

    azriley

      Title

      Communication Error: (22) The requested URL returned error: 401 - This can be due to an invalid username or password, or if the FMPHP privilege is not enabled for that user.

      Your post

           All,

           Having trouble connecting through PHP API to a fresh install of the demo Filemaker Server 13. Have a test script to show databases and list layouts (below). Databases do show but layouts fail with the message:

      Communication Error: (22) The requested URL returned error: 401 - This can be due to an invalid username or password, or if the FMPHP privilege is not enabled for that user.

           I have verified that the user has the privilege set. In fact that account has full access.

           Also ran through filemaker api documentation and tests like https://localhost:16000/test . I get successes on "Test FileMaker WebDirect", "Test PHP Custom Web Publishing", can view the database in the admin console (it has PHP enabled and all other options), can open the file (remote) and save changes...in short I can do everything but what I need which is connect via the API!

           Note sure what to check at this point. Any recommendations on how to connect via PHP API?

            

            

           Test code is below:

               require('FileMaker.php');

               $fm = new FileMaker();

               $fm->setProperty('hostspec', '192.168.1.12');
               $fm->setProperty('database', 'customdb'); // FMServer_Sample
               $fm->setProperty('username', 'user');
               $fm->setProperty('password', 'pass');


               $dbs = $fm->listDatabases(); /*will work regardless of validity of login */
               if (FileMaker::isError($dbs)) { /*can't connect to server*/
                   echo $dbs->getMessage();
                   exit;
               }
               echo"<pre>";
               print_r($dbs);
               echo "</pre>";

               $layouts = $fm->listLayouts();
               if (FileMaker::isError($layouts)) {
                   /*can't connect to database generally returns a 401 for invalid or unauthorized login*/
                   echo $layouts->getMessage();
                   exit;
               }
               echo"<pre>";
               print_r($layouts);
               echo "</pre>"