Unable to make more HTTP requests in Web Agent

I have a WebQueryOpen agent which connects to a WebPage which is basically a BluePages API Locator.In the Log, I check that it successfully connects.

But when I make a subsequent call where I pass a NotesID to a function, which is basically another web page request, I get the following messages in Web & the function returned nothing. The same done in Notes Client would return the Internet email for that NotesID.

These are messages in the Log for the subsequent function call:

02/13/2018 03:29:49 AM WEB(2): Loading additional WEB task

02/13/2018 03:29:49 AM WEB(3): Initializing

Please can anyone advise on how to do HTTP requests in a Web agent? Also, I cannot create Microsoft.HTTP objects since I use a Linux based web server.

I tried also getDocumentByURL but have not made any progress. :frowning:

Subject: Here’s a suggestion

post your code, you don’t for example say if you are using lotusscript or java.

If using Linux, I would suggest using Java.

Without seeing your code, we don’t know if you are using client side calls that aren’t available in Domino.

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/410171d83ddba6d485256df100832aba?OpenDocument

Subject: RE: Here’s a suggestion

Thanks for your reply & tips to NewComers on this forum.

My WebQueryOpen agent code is:

%REM

Agent VerifyUser

Created Feb 5, 2018 by Kingsley E Fernandes-1/India/IBM

Description: Comments for Agent

%END REM

Option Public

Option Declare

Use “BluePages”

Sub Initialize

On Error GoTo ErrHandle	

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim coll As BPResults

Dim bpd As BluePages

Dim curUser As NotesName

Dim dbProfileView As NotesView

Dim dbProfileDoc As NotesDocument

Dim http As Variant

Dim userEmail As String

Dim objHttp As Variant

Dim url As String

Dim req As Variant

Dim webDoc As NotesDocument

Dim rtItem As NotesRichTextItem



Set doc = s.Documentcontext

Set db = s.Currentdatabase

Set dbProfileView = db.Getview("Database Profile")

Set dbProfileDoc = dbProfileView.Getfirstdocument()



Set bpd = New BluePages(dbProfileDoc.APILocator(0)) 'which is the same as = New BluePages("http://bluepages.ibm.com/BpHttpApisv3/apilocator")



	

If Not bpd.IsOpen() Or bpd.GetReturnCode() <> 0 Then  

	MessageBox "Error in connecting to BluePages API",, "Error"

	Exit Sub

Else

	MessageBox "Connected to BluePages API"

End If

	

Set curUser = New NotesName(doc.Remote_User(0))	

MsgBox "In WQO agent: User logged in is " + doc.Remote_User(0) + " Abbv Name = " & curUser.Abbreviated



'Set coll = bpd.GetPersonByCnum("03350M")

Set coll = bpd.GetPersonsByNotesID(curUser.Abbreviated)

'Set coll = bpd.GetPersonsByNotesID("John O'Brien/Somers/Contr/IBM")

If coll.succeeded() Then

	MsgBox "BP message = " & coll.GetErrorMessage() & " code = " & coll.GetReturnCode()                       'If the query completed normally,

	If coll.rows() = 0 Then                    'No records found                               

		Msgbox curUser.Abbreviated & " was not found." & coll.GetColumn("name")  

	ElseIf coll.rows() >= 1  Then              ' coll.rows()>=1   ...and found at least one name,

		Msgbox "Name: " & coll.GetColumn("name") & " EMAIL = " & coll.GetColumn("INTERNET")(0)

	End if

End If



userEmail = coll.GetColumn("INTERNET")

'userEmail = "kingsfern@in.ibm.com"



MsgBox "To verify " & userEmail & " in ICA BlueGroups"



url = "https://tstbluepages.mkm.can.ibm.com/tools/groups/groupsxml.wss?task=inAGroup&email=" & userEmail & "&group=ICADEV"

Set objHttp = CreateObject("MSXML2.ServerXMLHTTP") 

objHttp.open "POST", url, False 

objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 

objHttp.send req



MsgBox objHttp.responseText



If InStr( objHttp.responseText, "<rc>0</rc>") <> 0 Then

	MsgBox "User is a Member of ICADEV BlueGroups"

Else	

	MsgBox "User is NOT a Member of ICADEV BlueGroups"

End If	

	



Exit Sub

ErrHandle:

MsgBox "WQO agent error on line = " & Erl & " with msg = " & Error$ 	

End Sub

The output in the Logs are:

02/14/2018 02:07:14 AM Agent message: Connected to BluePages API

02/14/2018 02:07:14 AM Agent message: In WQO agent: User logged in is CN=Kingsley E Fernandes-1/OU=India/O=IBM Abbv Name = Kingsley E Fernandes-1/India/IBM

02/14/2018 02:07:14 AM WEB(2): Loading additional WEB task

02/14/2018 02:07:14 AM WEB(3): Initializing

02/14/2018 02:07:15 AM Agent message: BP message = Success code = 0

02/14/2018 02:07:15 AM Agent message: Kingsley E Fernandes-1/India/IBM was not found.

02/14/2018 02:07:15 AM Agent message: To verify in ICA BlueGroups

02/14/2018 02:07:15 AM Agent message: WQO agent error on line = 77 with msg = Operation not supported on this platform

02/14/2018 02:07:15 AM Agent ‘VerifyUser’ error: No RESUME

Above shows that even though it has connected to BluePages, the subsequent call says the user is not found which is Incorrect.

Some related BluePages scriptlibrary code:

Class BluePages

Private webDb As NotesDatabase	' The local client's Web Retriever database.

Private webDBOpen As Integer		' Set to true if Web Retriever opens.

Private locatorURL As String		' URL for accessing API Locator, for API dictionary.

Private urlList List As String	' A dictionary of URLs, keyed by command names.	

Private listInPlace As Integer	' Flag to determine if API dictionary is loaded.

Private statusCode As Integer      ' Integer code to indicate the status.

Private errorMessage As String     ' Error message (if any) to indicate the status.



' 

' Constructs a new BluePages object with the specified URL for the Web Server

' API Locator. Opens the Notes Web Navigator to be used to retrieve outputs

' from URLs.

'

Sub New(locatorURL As String)

	' Default API Locator:

	'

	'	http://tstbluepages.mkm.can.ibm.com/BpHttpApisv3/apilocator

	'		

	Me.locatorURL = locatorURL

	

	Me.listInPlace = False 

	

	Set Me.webDb = New NotesDatabase("", "")

	If Not Me.webDb.OpenURLDb Then   

		' On Notes client, false if Open/Retrieve Pages is "from

		' Notes workstation" and Web Navigator Database is

		' blank or if Open/Retrieve Pages is "no retrievals" and

		' Web Navigator Database is blank or nonexistent..

		' Messagebox "Error: Configuration for Web Navigator is incorrect", , "BluePages Script Library"

		Me.statusCode = 1

		Me.errorMessage = "Unexpected error occurred due to invalid Web Navigator configuration."			

		Me.webDBOpen = False

	Else

		Me.statusCode = 0

		Me.errorMessage = ""

		Me.webDBOpen = True

	End If		

End Sub

Function GetPersonsByNotesID(template As String) As BPResults

	Set GetPersonsByNotesID = GetBPResults("ALLBYNOTESID", template & "%")		

End Function

’ Returns a BPResults object representing the result table constucted based on

’ the results to be retrieved for the specified Web Server API query function

’ (opName) and the query string (opArg).

Private Function GetBPResults(opName As String, opArg As String) As BPResults

	Dim bpe As BPEnumerator

	

	If Me.IsOpen() Then

		opArg = Trim$(opArg)

		

		' If argument is missing, warn..		

		If opArg ="" Or opArg = "%" Then

			Set bpe = Me.GetFailedBPEnumerator(opName & " requires a string argument.")

		Elseif opArg = "+" Then

			Set bpe = Me.GetFailedBPEnumerator(opName & " requires two string arguments.")

		Else							

			' If argument is present, fetch data from BluePages..

			

			' Is the API dictionary is loaded?

			If Me.URLListReady() Then	

				' Does the specified query function exist?

				If Iselement(Me.urlList(opName)) Then

					Set bpe = Me.GetBPEnumerator(Me.urlList(opName) & URLEncode(opArg))

				Else 

					' The specified query function does not exist..

					Set bpe = Me.GetFailedBPEnumerator("Command: " & opName & " not found in the API dictionary.")

				End If

			Else

				' The API dictionary is not loaded..

				Set bpe = Me.GetFailedBPEnumerator("The API locator function failed to load the API dictionary.")

			End If			

		End If

	Else 

		Set bpe = Me.GetFailedBPEnumerator("Cannot complete the request due to invalid Web Navigator configuration.")

	End If

	

	Set GetBPResults = New BPResults(bpe)		

End Function

So the first problem is that it does not fetch the user from getPersonsByNotesID which triggers the log messages: “WEB(2): Loading additional WEB task & WEB(3): Initializing” and the second problem is that I cannot use CreateObject(“MSXML2.ServerXMLHTTP”) which triggers the log message: Operation not supported on this platform.

Please advise for a workaround. Thank.

Subject: RE: Here’s a suggestion

So I think your issue is OpenURLDb is for the Notes client as it uses the Notes Web Navigator (very old tech) to fetch the web details, not sure that will do anything on the domin server

You would be better off using Java if you are going to do this on the server anyway. I’d search google for:

domino java agent http request

Also as this obviously an internal IBM piece of code, perhaps you can get help within the IBM forums on W3?

Subject: RE: Here’s a suggestion

Thanks Carl for your advice.

I found out the error in the subsequent web call. I had to pass a URL safe encoded argument in that HTTP call for the Server’s Web Navigator to process it properly. In Client, the same code was processed by my local Personal Web Navigator & it worked fine.

Now I am stuck on the second part, usage of SXML2.ServerXMLHTTP objects on a Linux Server. It says “Operation not supported on this platform”.

So I used getDocumentByURL to fetch the webpage but the results are stored in a $FILE attachment which I am now trying to read the attachment without physically extracting the file to the Server disk.

Is the possible? Any suggestions? I have to just search for the string 0 which means return code is 0 if the email is a member of the BlueGroups else not a member.

Thanks!