Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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


This topic is 2578 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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>

 

Posted

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

Posted

 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 

Posted
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>

 

This topic is 2578 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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