Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need Help Getting Started Testing out FMS Data API with localhost HTML Pages

Featured Replies

Hi All,

I am trying to set up a very basic HTML page to test out the FileMaker 16 Data API.

I am on a Mac - EL Cap Test server: First of all I am using the Postman app on local host FileMaker server. I have got that working pretty well with success with scripts. I am attempting to take those settings and put them into an HTML web page. 

The first thing I am trying to do is try getting an authorization token using the post method with HTML web page.

Currently, the pages are coming back BLANK including the console log so it's hard to track.

Question: any ideas on how to get this set up?

Here is my example test below– Any assistance would be appreciated.

Thanks - Dave


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>auth test Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>


<script>
$(document).ready(function(){
   $("button").click(function(){
       $.post("https://localhost/fmi/rest/api/auth/testfile",
       {
		headers: { 'Content-Type': 'application/json' }, // is this the right way to send headers
		user: "webtest",
		password: "webtest",
		layout: "webtest"				

       },
       function(data,status){
           alert("Data: " + data + "\nStatus: " + status);
	    console.log ('data', data);
       });
   });
});
</script>
</head>
<body>

<button>Send an HTTP POST request</button>

</body>
</html>

 

I do recommend to use FireFox </> RESTED-addon to make your queries the first couple of times so that you know which pieces of data you are to work with. Further I would not use jQuery, rather use Angular, vue, or react as the latter 3 are for HTML5, jQuery I have not used since XHTML/HTML4

 

 

Screen Shot 2017-10-19 at 11.22.20 PM.png

  • Author

 Thanks for your help. I added the plug into Firefox but I’m not sure how to get it started. I don’t see any rested menu choices in Firefox. I also could not find any documentation on how to get up and running. Can you provide any insights?

 Also if you could comment on the  HTML page I provided and let me know why that is only producing a white page and no console activity or anything I would greatly appreciate it 

  • Author
Hi,
 
Update - after a few simple mods - now the web pages are working ok...
 
 
EX: 
<script>	
 
$(document).ready(function(){
 
	 var settings = {
	  "async": true,
	  "crossDomain": true,
	  "url": "https://localhost/fmi/rest/api/auth/test",
	  "method": "POST",
	  "headers": {
		"content-type": "application/json",
		"cache-control": "no-cache"
	  },
	  "processData": false,
	  "data": '{"user":"xxx","password":"xxx","layout":"xxx"}'
	}

	$.ajax(settings).done(function (response) {
	  console.log('auth call response', response);
		 

document.getElementById('demo').textContent = response.token;

});
 
 
 // end 
});
 			 
</script>

 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.