The htmlConnection function is required to use a webservice on the internet. Any webservice can be used, which provides a REST API, accepting or returning JSON objects.
In order to initiate a new connection to a webservice, we have to create a connection object by calling the function "htmlConnection".
This function returns a GUID (globaly unique identifier string), which must be used later on, in order to set header, content or to send a request to a webservice.
In the example below, we are using the jsonplaceholder webservice for testing only. We send a GET request to its URL and show the result in a message box.
Note: You can use the JSON functions in order to parse the returning JSON result string from a webservice.
Returns:
Type |
Value |
Description |
String |
String |
A globaly unique identifier string, which is used to identify the new connection within the connection pool.
For example: 9EF7B29A-0666-4868-9DB0-DE96ED99C20B |
Available in:
WindowMain |
WindowLink |
YES |
YES |
Used in:
XojoScript Name |
GUID |
Send SMS to selected addresses |
8A16D48E-5495-4E9C-8B40-9AFBA231CC96 |
|
|
Hint: You can find references to XojoScripts which make use of this function by sending the following SQL statement to the database:
Select id,GUID, ScriptName,ScriptCode from im_scripts where ScriptCode Like '%htmlConnection%'
Example XojoScript:
// Create new URLConnection
Dim conID AsString= htmlConnection
// Send a GET request to webservice
Dim response AsString
response = htmlSendSync(conID,"GET","https://jsonplaceholder.typicode.com/todos/8",15)
// show resulting JSON string to user
MsgBox(response)
// Release connection
Call htmlConnectionClose(conID)