Data API won't update record

Hello. I am using the Data API from within a web viewer in my solution. I have built a custom map using the Google Maps API that the user can draw with. When they are finished, they press send to send the coordinates to FileMaker. (Using Data API for WebDirect purposes) Anyway, for the life of me, I cannot send some data through the API. I can get the initial drawing and send it through correctly. The data being sent through looks like this:


If I update the drawing and try to send the updated coordinates through, nothing happens. I can send any other data, but not the new set of coordinates. Of note, the new set is formatted as:


Any idea why this is? I tried manually throwing brackets around the new set of coordinates, and still nothing happened.

Can we see the JS code that sends the data through to the server using the Data API? Please remove your credentials though! We might be able to see an issue.

And the lack of square brackets in the new set, to me suggests the JSON data is not being stringified before sending. ie, JSON.stringify(your array).


It is not clear from your description whether the call to the Data API does not happen when you update the coordinates or whether the call does happen but the FM record is not updated.

function fmScript() { 
  var fmScript = new XMLHttpRequest();   
  fmScript.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        var responseData = JSON.stringify(JSON.parse(this.responseText);   
  };"PATCH", "https://{{HOSTNAME}}/fmi/data/vLatest/databases/{{FILENAME}}/Layouts/Estimates_Form_iPad/records/13", true);   
  fmScript.setRequestHeader("Authorization", "Bearer " +  accessToken);
  fmScript.setRequestHeader("Content-type", "application/json");
  var JSONCoords = document.getElementById("newSplit").value;
  var JSONAreaArray = document.getElementById("newArray").value;
  var fieldJSON = '{ "fieldData": { "Map_Site_Coords_Site": "' + JSONCoords + '", "Map_Site_AreaArray_Site": "' + JSONAreaArray + '" } }'; 

As updates are made with the map, those updates are stored in hidden input fields. The text I wish to send comes from those fields.

The variable that will not send is stored in that snippet as JSONCoords. I have tried the JSON.stringify() method, but that didn't work either.

I don't know if you need to see the rest of the code. JavaScript is not my strong suit, that's for sure.

I apologize. The call does happen, and no errors are recorded. It simply doesn't update the record in FM.

I would suggest adding code after the "fmScript.send(fieldJSON)" call to check the response and make sure you're not getting an error.
I'd also be weary of building json by just concatenating text, if something is off (as in: not json-compatible) in either JSONCoords or jsonAreaArray then you would be sending invalid json.

Also check the FMS Data API log, each log gets recorded there, not the payload through but at least you can verify that it made it to the FMS.

You're always updating record with recordId 13, is that meant to be that way?


That was just from my testing. I have my test web viewer, and my live web viewer. The live one will contain Get ( RecordID ).

+1 to both of the above thoughts.

The code shown in your post above only checks the response if it is successful (status == 200), and even then it doesn't appear to do anything to provide you any client-side feedback about what happened to help with trouble-shooting

For the time being, and just for the purposes of debugging:

I'd suggest removing the this.status == 200 condition, and then also have the code in the onreadystatechange handler function report back to you both the value of this.status and this.responseText so that you can have more insight into what has happened.

HTH & sincerely,



That is what I ended up doing. It appears there is a problem with how I'm forming my JSON to send back to FM. I'm in the process now of cleaning it up thoroughly, and re-testing to make sure I didn't delete anything necessary.


It did end up being an error with the way I built my JSON. It's working now. Thanks everybody!