Make HTTP requests with Basic

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
psilocybe
Posts: 117
Joined: Thu Jun 15, 2017 5:33 am

Make HTTP requests with Basic

Post by psilocybe »

Hi all,

It is possible to make HTTP requests with Basic.

Restrictions apply to the use of OpenOffice under Windows. Please see the documentation for more information.

You must first install the OAuth2OOo extension.

and here is an example of Basic code:

Code: Select all

Rem  *****  BASIC  *****

Sub Main

Rem First we need to create the UNO OAuth2Service
oauth2 = CreateUnoService("io.github.prrvchr.OAuth2OOo.OAuth2Service")

Rem To execute an HTTP request we first need a HTTP Request parameter
parameter = oauth2.getRequestParameter("httpbin")

Rem Default Requests method is GET but can be changed (ie: parameter.Method = "PUT")

parameter.Url = "https://httpbin.org/ip"

Rem Default authentication is OAuth2 but can be disabled with:
parameter.NoAuth = True

Rem To obtain the HTTP response we use the execute() method
Rem of the OAuth2Service service with the HTTP parameter as argument
response = oauth2.execute(parameter)

If response.Ok Then
    Msgbox response.Text
End If

Rem When it's finished we have to close the HTTP response
response.close()

End Sub
oauth2 is defined in the idl file XOAuth2Service.idl
parameter is defined in the idl file XRequestParameter.idl
response is defined in the idl file XRequestResponse.idl

Enjoy...
LibreOffice 5.3.3.2 - Lubuntu 16.10 - LxQt 0.11.0.3
Post Reply