I’m trying to POST a new record to one FileMaker Database using Temper. I successfully follow the webinar and I can get records from database and insert them into one ListBox.
Now I need to post a new record from the information of some text field and I really don’t know the steps to do it correctly.
I’m looking for an example of this kind of http request or the indications to do it.
Temper is a Web API for hosted FileMaker databases. With Temper, you can make API calls to create, read, update, and delete records, run scripts, work with containers, and more.
Var sock As New URLConnection
// Set up the POST values to send to the Temper API using a Dictionary
Var postInfo As New Xojo.Core.Dictionary
postInfo.Value("Host") = "host"
postInfo.Value("Protocol") = "https"
postInfo.Value("Database") = "database"
postInfo.Value("Account") = "username"
postInfo.Value("Password") = "password"
postInfo.Value("Layout") = "layout"
postInfo.Value("Action") = "InsertRecord"
// Set the sort for the data so we can request it in chunks if necessary
Dim sortField1 As New Xojo.Core.Dictionary
sortField1.Value("Store Name") = "Test"
sortField1.Value("Stree 1") = "100 Test Avenue"
Dim Fields() As Xojo.Core.Dictionary
Fields.Append(sortField1)
postInfo.Value("Fields") = Fields
// Convert the Dictionary to JSON text
Dim json As Text
json = Xojo.Data.GenerateJSON(postInfo)
// Add the POST data to the RequestContent and send the POST request
sock.SetRequestContent(json, "application/x-www-form-urlencoded")
sock.Send("POST", "http://127.0.0.1:8080")
The json is a little different than request I need to post. I need to remove the “[” from the second dictionary (Fields) in order get the post working fine.
I think that the second dictionary is not the correct way to code . Any idea how can I remove it? This is the JSON