amberdextrous
MIS
Warning, I'm an extreme newbie to this stuff, I'm actually an intern so I'm still learning. I wasn't sure who would be more likely to know how to help me, FileMaker experts or ASP.NET experts, so I posted in both forums.
I am trying to send GET and POST requests to a web-enabled FileMaker database using a ASP.NET web service. I got my Find function working, and I am now able to run queries against the database using HTTP GET and the results are returned to me as XML. However, I am still having a problem with adding new records. I can add a new record with GET, but not POST. From my understanding, URIs have a length limit, and I've read that POST can be used in place of GET to avoid this limitation. I tried implementing a POST function based on sample code I saw, but I have a feeling I did it completely wrong. Like I said, I'm new to web services so forgive me.
This code works:
And this code works:
This code DOESN'T work:
I think I read somewhere that adding FileMaker records can only be done with GET. Yet, when I view the web-enabled database in the browser and click "New record", a blank form comes up and when I left-click and select "View source code", FORM METHOD=POST is in the code. So there must be a way to do it in ASP.NET. Does anyone know how?
FWI, once I get this working, I will be parsing XML sent from a VB.NET app and transferring it to a web-enabled FileMaker database. What I'm doing now is just testing, because I obviously can't do the rest until I get the POST/GET functions working.
I am trying to send GET and POST requests to a web-enabled FileMaker database using a ASP.NET web service. I got my Find function working, and I am now able to run queries against the database using HTTP GET and the results are returned to me as XML. However, I am still having a problem with adding new records. I can add a new record with GET, but not POST. From my understanding, URIs have a length limit, and I've read that POST can be used in place of GET to avoid this limitation. I tried implementing a POST function based on sample code I saw, but I have a feeling I did it completely wrong. Like I said, I'm new to web services so forgive me.
This code works:
Code:
<WebMethod()> _
Public Function Find() As String
Dim uri As New Uri("[URL unfurl="true"]http://localhost:8888/FMPro?-db=TABLENAME.fp5&-format=-dso_xml&field1=value1&-find")[/URL]
Dim credentials As NetworkCredential
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
credentials = New NetworkCredential("", "password")
request.Credentials = credentials
request.Method = WebRequestMethods.Http.Get
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetResponseStream())
Dim xml As String = reader.ReadToEnd()
response.Close()
Return xml
End If
End Function
And this code works:
Code:
<WebMethod()> _
<WebMethod()> _
Public Function AddRecordWithHTTPGet() As String
Dim uri As New Uri("[URL unfurl="true"]http://localhost:8888/FMPro?-db=TABLENAME.fp5&-format=-fmp_xml&field2=value2&-new")[/URL]
Dim credentials As NetworkCredential
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
credentials = New NetworkCredential("", "password")
request.Credentials = credentials
request.Method = WebRequestMethods.Http.Get
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetResponseStream())
Dim xml As String = reader.ReadToEnd()
response.Close()
Return xml
End If
End Function
This code DOESN'T work:
Code:
<WebMethod()> _
Public Function AddRecordWithHTTPPost()
' I get a "Format file not found" error:
Dim uri As New Uri("[URL unfurl="true"]http://localhost:8888/FMPro?-db=TABLENAME.fp5&-format=-fmp_xml&-lay=webdown")[/URL]
Dim param1 As String = "field3=value3&-new"
Dim credentials As NetworkCredential
If uri.Scheme = uri.UriSchemeHttp Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
credentials = New NetworkCredential("", "password")
request.Credentials = credentials
request.Method = WebRequestMethods.Http.Post
request.ContentLength = param1.Length
request.ContentType = "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
Dim writer As New StreamWriter(request.GetRequestStream)
writer.Write(param1)
writer.Close()
Dim oResponse As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(oResponse.GetResponseStream())
Dim xml As String = reader.ReadToEnd()
oResponse.Close()
Return xml
End If
End Function
I think I read somewhere that adding FileMaker records can only be done with GET. Yet, when I view the web-enabled database in the browser and click "New record", a blank form comes up and when I left-click and select "View source code", FORM METHOD=POST is in the code. So there must be a way to do it in ASP.NET. Does anyone know how?
FWI, once I get this working, I will be parsing XML sent from a VB.NET app and transferring it to a web-enabled FileMaker database. What I'm doing now is just testing, because I obviously can't do the rest until I get the POST/GET functions working.