0

I am trying to access an API using the REST feature. But I can't retrieve the data.

Here the code

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

URL = "https://www.meteoblue.com/en/server/search/query3?query=basel"

ret  = webrequest.Get(URL)

Messagebox ret

I already solved my previous problem with this solution, but I have another error now. When I run this code, I get the following error (The problem is with "ret"):

Type mismatch in method OP_CHECK_TOS_BYVAL : BYTE found, Unknown expected

Does anyone have any idea what the problem is?

Q. Suisse
  • 107
  • 8
  • Does this answer your question? [Lotusscript NotesHTTPRequest Issue](https://stackoverflow.com/questions/54073170/lotusscript-noteshttprequest-issue) – Tode Nov 17 '20 at 10:39
  • Error handler? Please add an error handler to see the LINE where this error occurs... This line `Messagebox ret` -e.g.- cannot work because Messagebox expects a string and not a variant... – Tode Nov 17 '20 at 10:55
  • ask HCL for why they decided to go with that implementation, I have no idea... – Tode Nov 17 '20 at 11:29

1 Answers1

3

I repeat myself like a broken record: Add error handler to EVERY LINE OF CODE.

In your example you have exactly 4 lines of code where something can go wrong. And nevertheless you can't find out, which of the 4 lines causes the error if you don't use error handling (of course you could by using the debugger, but this is another story...).

Without an error handler I can only guess, that your error comes from this line:

Messagebox ret

ret is defined as Variant and the help of the function tells you, that it will return a byte array:

Return value Variant

Returns Variant content as JSON UTF8 byte array. Use the preferstrings property to return Unicode rather than UTF8 byte array.

But Messagebox expects a String as parameter --> Type mismatch...

Tode
  • 11,795
  • 18
  • 34