Subject: Retrieving results from external HTTP POST
Send the post to an notes agent.
Do something like:
Agent code:
Dim ses As New NotesSession
Dim doc As NotesDocument
Dim urlBase As String
Dim tmp() As Variant
Set doc = ses.DocumentContext
’ Parse out the return url
If ParseRequestContent(doc.Request_Content(0), tmp, “urlBase”) = False Then Error 1292, “Missing urlBase argument” ’ To get the value of urlBase
urlBase = tmp(0)
’ Some functions
Function ParseRequestContent (requestContent As String, resultArray() As Variant, parameter As String) As Integer
' This finction is usable in agents that get an form posted to it with the 'post-method'
' The data comes in the cgi variable request content to the agent (get it with DocumentContext)
' This function make all decoding and stuff, so the requestContent parameter can be supplied 'as is'
' The return value is set to true if averything went well (no error and that it was at least one value found)
' The resultArray is where the result should be 'saved'
' The parameter-parameter is case insensitive
ParseRequestContent = False
On Error Goto errorHandler
Dim rc As String
Dim a As Integer
Dim p As Integer
rc = "&" + DecodePlus(requestContent) ' the ampersand is there to make sure the string starts with an ampersand
a = -1
p = Instr(Lcase$(rc), "&" + Lcase$(parameter) + "=")
While p>0
a = a + 1
If a = 0 Then
Redim resultArray(a) As Variant
Else
Redim Preserve resultArray(a) As Variant
End If
resultArray(a) = Parse(rc, parameter)
rc = Mid$(rc, p+3)
p = Instr(Lcase$(rc), "&" + Lcase$(parameter) + "=")
Wend
If a = -1 Then Error 1201, "No parameter found"
ParseRequestContent = True
exitParse:
Exit Function
errorHandler:
ParseRequestContent = False
Resume exitParse
End Function
Function DecodePlus (encString As String) As String
' Denna rutin ersätter först alla + tecken med blanksteg innan han kallar på Decode
Dim i As Integer
For i = 1 To Len(encString)
If Mid$(encString, i, 1) = "+" Then
Mid$(encString, i, 1) = " "
End If
Next
DecodePlus = Decode(encString)
End Function
Function Decode(encString As String) As String
' Avkodar en sträng som innehåller %hh i sig där procent hh står för ett hexadecimalt värde på ett tecken
' Blir det fel returnerar rutinen en tom sträng
On Error Goto errorHandling
Dim i As Integer
Dim vString As String
i = Instr(encString, "%")
Do While i > 0
vString = Mid$(encString, i + 1, 2)
encString = Left$(encString, i -1) + Chr$(Cint("&H" + vString)) + Mid$(encString, i + 3)
i = Instr(i+1, encString, "%")
Loop
Decode = encString
Exit Function
errorHandling:
Decode = ""
End Function
I really dont know if I would do like this today. But we always learn new stuff 