Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

    Domino V10 - HTTP Requests and REST Services from Lotus Script

    Daniel Nashed  11 October 2018 00:55:16

    One of the long missed features in Lotus Script is to work with HTTP requests.
    Since Notes/Domino V10 you can now use HTTP requests directly from Lotus Script -- For example to query data from a website or from a REST service.

    In the beta I played around with it already. I was specially interested in authentication and HTTPS.

    HTTPS now works and authentication can be implemented on your own. The a bit tricky part is the Base64 routine that you need for the authorization header. But there is a way to leverage the MIME classes for that.

    So the following example helps you to get started. It builds the authentication header and also uses HTTPs to request a website.
    Tip: Depending on the request you might run into issues with too many redirects which the function does not follow automatically. So you have to increase the limit as shown in the example.

    For HTTPS the certificate needs to be verified. I have tested with my Let's Encrypt Certificated and it worked well.

    Another tip: If you run into issues with certificates or other parts of the NotesHTTPRequest, there is a debug notes.ini setting Debug_NotesHTTPRequest=1.

    I have tested the following example with the Notes V10 GA client.
    The Designer help has some additional information also for the other functions of that class.


    -- Daniel

    Option Declare

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

            user = ""
            password = "mypassword"
            URL = ""
            Call webRequest.Setheaderfield("Authorization", "Basic " + EncodeBase64 (user + ":" + password))
            ret  = webrequest.Get(URL)
            headers = webRequest.GetResponseHeaders()
            ForAll h In headers
                    MessageBox h
            End ForAll
            MessageBox ret
    End Sub

    Function EncodeBase64 (StrIn As String) As String
            Dim session As New NotesSession
            Dim stream As NotesStream
            Dim db As NotesDatabase
            Dim doc As NotesDocument
            Dim body As NotesMIMEEntity

            Set stream = session.CreateStream
            Call stream.WriteText (StrIn)
            Set db = session.CurrentDatabase
            Set doc = db.CreateDocument
            Set body  = doc.CreateMIMEEntity
            Call body.SetContentFromText (stream, "", ENC_NONE)
            Call body.EncodeContent (ENC_BASE64)
            EncodeBase64 = body.ContentAsText
            Call stream.Close
            Set doc = Nothing
    End Function

    1Brian Benson  11.10.2018 5:52:42  Domino V10 - HTTP Requests and REST Services from Lotus Script

    Thanks, Daniel. I looked at the docs on this today but didn't find it very helpful.

    Have you explored parsing JSON with LotusScript yet?

    2Sean Cull  11.10.2018 9:00:25  Domino V10 - HTTP Requests and REST Services from Lotus Script

    I have used this code from OpenNTF on a demo but it was a couple of years ago.

    3Ed  11.10.2018 10:20:24  Domino V10 - HTTP Requests and REST Services from Lotus Script

    How to set proxy?

    4Karli  11.10.2018 11:29:31  Domino V10 - HTTP Requests and REST Services from Lotus Script

    Did anyone successfully made a POST request to a https endpoint? I'm always getting strange results like access denied or 500 errors.

    You can try this endpoint

    5Daniel Nashed  11.10.2018 13:31:16  Domino V10 - HTTP Requests and REST Services from Lotus Script

    @Brian, I saw an example in a presentation but I have not used it on my own.

    The purpose of my post was more to show how it works and specially what you have to do to get it working with https and authentication.

    I am not working on an application based on it right now. I am working on other stuff for Domino V10 right now.

    -- Daniel

    6Alex  14.11.2018 18:51:16  Domino V10 - HTTP Requests and REST Services from Lotus Script

    Karli, I succeeded in submitting POST actions to a REST Service with the help of 2 script libs from Robert Ibsen Voith.

    Just tried the URL you works.

    If you need help you can contact me:

    7Amit Sharma  17.01.2019 6:30:13  Domino V10 - HTTP Requests and REST Services from Lotus Script

    Hi Nash,

    How is this different from MSXML2.XMLHTTP?

    Does MSXML2.XMLHTTP have any advantage over NotesHTTPRequest?

    If the requirement is collecting and analysing information of website as text, which method should be used -->

    MSXML2.XMLHTTP or NotesHTTPRequest on V10.


    Amit Sharma

    8Daniel Nashed  17.01.2019 11:07:15  Domino V10 - HTTP Requests and REST Services from Lotus Script

    Hi Amit!

    MSXML was an add-on not something that comes with Notes/Domino out of the box! And it only works on Windows!

    The solution is also legacy as the Wikipedia entry says -->

    Having it available directly in Lotus Script has a couple of benefits.

    - Fully supported by IBM

    - Works cross platform

    - Does not need any deployment!

    -- Daniel

    9Frank Bueschler  04.02.2019 15:21:34  Domino V10 - HTTP Requests and REST Services from Lotus Script

    We also had strange results with this code example. Took some time to figure out, that the EnodeBase64 function is adding line-feeds to the resturn string.


    • [IBM Lotus Domino]
    • [Domino on Linux]
    • [Nash!Com]
    • [Daniel Nashed]