Search code examples
lotus-noteslotus-dominolotusscript

Lotusscript NotesHTTPRequest Issue


I'm trying to use the new Rest features in LotusScript (Notes Client Release 10.0.1) to retrieve address information from Google. Unfortunately, I get an error when trying to get a response. If I try the same url in the browser, I get no errors. There is no proxy configured.

Here's some sample code

Dim Session As New NotesSession        
Dim ret As String
Dim URL As String
Dim headers As Variant
Dim webRequest As NotesHTTPRequest
Set webRequest = session.createhttprequest()

url = "https://maps.googleapis.com/maps/api/geocode/json?address=Antwerp&<my Google API key>"

ret  = webrequest.Get(URL)

When I run this code in an agent, I get the following error on the last line:

Type mismatch in method CoerceString: Unknown found, Unknown expected


Solution

  • The documentation for that command states:

    Return value
    Variant

    Returns Variant content which contains JSON string.

    And the error message that you get is typical for getting a variant and trying to cast it to a string.

    The strange thing: With some websites it seams to work (probably depending of the type of data the website returns) with

    Dim ret as String
    

    Although the documentation is wrong in stating that the variant contains a JSON string (indeed it simply contains whatever the called website returns, that might be a JSON string, but can simply be the source code of the website as well), it still is right, that one should expect a variant as return value.

    So this line should work:

    Dim ret as Variant