Set request content of an existing htmlConnection
object.
Data to be send to a webservice must be a JSON string.
Use the example script below to test this function
against our test webservice (https://test.nwscloud.ch/test)
Parameters:
Name |
Type |
Description |
conID |
String |
Identifier of existing htmlConnection
object |
content |
String |
Valid JSON string |
mimeType |
String |
application/json |
Returns:
Type |
Value |
Description |
String |
OK |
The request content has been set |
String |
ERROR |
Setting of the request content failed |
Available in:
WindowMain |
WindowLink |
YES |
NO |
Example XojoScript:
// Create new URLConnection
Dim conID As String = htmlConnection
// Set contents as JSON string
Var json As String = "{""id"":12345,""name"":""John
Doe"",""email"":""jd@example.com""}"
// Set Request header contents (send data)
Var content As String = htmlRequestContent(conID,json,"application/json")
If content = "ERROR" Then
MsgBox("ERROR : Setting request content header failed.")
Call htmlConnectionClose(conID)
Return
End If
// Define path to test webservice
Dim url As String = "https://test.nwscloud.ch/test"
// Send Update Request for current address to
Webserver
Dim jsonresponse As String = htmlsendSync(conID,"POST", url,15)
MsgBox("Response : " + jsonresponse)
Call htmlConnectionClose(conID)