I want to send data to a server with a POST request. In my case, I have an agent that will retrieve the information from the open email to send this data to the servers. But for the data transmission (HTTP POST), I need to provide data in JSON format in params.
However I have not found anywhere clear information on how to create a JSON with data. I can easily retrieve the data from the email but I don't know how to convert it to JSON. Is it possible to do this easily? Does anyone have a solution?
This simple example should help you.
Dim session As New NotesSession
Dim url As String
Dim jsonBody As String
url="https://example.com"
jsonBody="{'param 1:'value 1'}"
Dim http As NotesHTTPRequest
Set http=session.CreateHTTPRequest()
Call http.SetHeaderField("ContentType","application/json")
Call http.Post(url,jsonBody)
The json content in the example is built using a string called jsonBody. Here's an example where you build the string using other variables:
Dim lastname As String
lastname="Richards"
jsonBody="{'param 1':'" + lastname + "'}";