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:
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.
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?
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.
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.