October 19, 20178 yr 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>
October 19, 20178 yr 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
October 20, 20178 yr 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
October 22, 20178 yr 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