Hi there where ever you are
This works in the case that the server does not
require the HEADER parts of the requests to be set:
Sub GetStocks
Dim URL As String
Dim response As String
Dim pos As Long
Dim oServiceManager As Object
Dim oSimpleFileAccess As Object
Dim oInputStream As Object
Dim oTextInputStream As Object
URL = "https://example.com/stocks/" '(does not match the domain name used)
oServiceManager = GetProcessServiceManager()
oSimpleFileAccess = oServiceManager.createInstance("com.sun.star.ucb.SimpleFileAccess")
oInText = createUNOService("com.sun.star.io.TextInputStream")
oInputStream = oSimpleFileAccess.openFileRead(URL)
oInText.setInputStream(oInputStream)
Do While Not oInText.isEOF()
line = oInText.readLine()
response = response & line & Chr(10)
Loop
...
...
End Sub
I can’t get this working:
Sub GetStocksWithHeaders()
Dim URL As String
Dim response As String
Dim oServiceManager As Object
Dim oWebDAV As Object
Dim oInputStream As Object
Dim oTextInputStream As Object
URL = "https://example.com/stocks/"
oServiceManager = GetProcessServiceManager()
oWebDAV = oServiceManager.createInstance("com.sun.star.ucb.WebDAVDocumentContent")
REM The code fails here:
oWebDAV.setPropertyValue("URL", URL)
REM Returns:
REM BASIC execution error.
REM '91'
REM Object variable not defined.
'This makes no difference:
'oWebDAV.setPropertyValue("GET", URL, False)
oWebDAV.setPropertyValue("ContentType", "text/json")
oWebDAV.setPropertyValue("UserAgent", "LibreOffice")
oInputStream = oWebDAV.openInputStream()
oTextInputStream = createUNOService("com.sun.star.io.TextInputStream")
oTextInputStream.setInputStream(oInputStream)
response = ""
Do While Not oTextInputStream.isEOF()
response = response & oTextInputStream.readLine()
Loop
oTextInputStream.closeInput()
oInputStream.closeInput()
...
...
End Sub