XMLHTTP30 Problem - Caching? (1 Viewer)

KernelK

Registered User.
Local time
Yesterday, 20:50
Joined
Oct 3, 2006
Messages
173
I haven't found too much help with the XMLHTTP30 object yet, but here goes another question about it. Posted below is the code for a function I am using that posts data to a web database via a php API. The first portion (the part that uses the POST method with the XMLHTTP30 object, works fine the data is transferred to the web database.

The second portion is used to retrieve the information from the web database so that I can pull the web databases ID number for the ticket, that way I can link the two databases together (if I need to refer to it by the web database number later). Now, everytime I use the GET mothod with the object, it will always return the same exact responseText. It is as if it is returning a cached copy. It will never show me any of the new items I add in, until I exit completely out of Access and return to my DB. After that it will show me all of my new items up to that point, but then keeps pulling this new cached copy until I exit Access. Am I not closing something properly, or is there a switch I'm unaware of that will allow me to force a new copy (and not a cached one) each time. I'm at my wits end on this, so any help or insight is appreciated.

Code:
Function PostToSyn(ByVal strTitle As String, ByVal strNotes As String, ByVal intPID As Integer) As SYN_RESPONSE
    Dim oHttpReq As XMLHTTP30
    Dim strUser As String
    Dim strParam As String
    Dim strCleanTitle As String
    Dim strCleanNotes As String
    
    If IsNothing(DLookup("SynID", "tblAgent", "Login = '" & CurrentUser & "'")) Then
        DoCmd.OpenForm "frmSynergiGetUser", acNormal, windowmode:=acDialog
        
        If Not IsFormLoaded("frmSynergiGetUser") Then
            PostToSyn.Pass = False
            Exit Function
        Else
            DoCmd.Close acForm, "frmSynergiGetUser", acSaveNo
        End If
    End If
    
    strCleanTitle = CleanNotes(strTitle)
    strCleanNotes = CleanNotes(strNotes)
    
    strUser = DLookup("SynID", "tblAgent", "Login = '" & CurrentUser & "'")
        
    strParam = "q=log&pid=" & intPID & "&title=" & strCleanTitle & "&notes=" & strCleanNotes & "&posted_by=" & strUser
    
    Set oHttpReq = New XMLHTTP30
    
    With oHttpReq
        .Open "POST", gstrURL, False
        .SetRequestHeader "Content-type", "application/x-www-form-urlencoded"
        .SetRequestHeader "Content-length", Len(strParam)
        .SetRequestHeader "Connection", "close"
        .Send (strParam)
    End With
    
    If oHttpReq.responseText <> "0" Then
        MsgBox "There was a problem processing your request.  Contact the DB administrator for help if the problem persists.", vbOKOnly, gstrAppName
        PostToSyn.Pass = False
        Exit Function
    Else
        PostToSyn.Pass = True
    End If
    
    Set oHttpReq = Nothing

    If intPID = 0 Then
        Dim oXMLDoc As DOMDocument30
        Dim oNode As IXMLDOMNode
        Dim blnMatch As Boolean

        Set oHttpReq = New XMLHTTP30
        Set oXMLDoc = New DOMDocument30
        
        strParam = gstrURL & "?q=notes&archived=0"
    
        oHttpReq.Open "GET", strParam, False
        oHttpReq.Send
        blnMatch = False
    
        oXMLDoc.loadXML (oHttpReq.responseText)
        Set oNode = oXMLDoc.selectSingleNode("notes")
        
        If oNode Is Nothing Then
            MsgBox "The note was posted, but I could not retrieve its Synergi ID, please inform the DB Admin", vbInformation, gstrAppName
            PostToSyn.Retrieved = False
            Exit Function
        End If
        
        If oNode.childNodes.Length > 0 Then
            Dim uNode As IXMLDOMNode
            Dim strNoteID As String
            For Each uNode In oNode.childNodes
                If uNode.childNodes(4).nodeTypedValue = strTitle Then
                    blnMatch = True
                    strNoteID = uNode.childNodes(0).nodeTypedValue
                    Exit For
                End If
            Next uNode
            
            If blnMatch = True Then
                MsgBox "The note was posted and the DB is now linked to this Synergi ticket", vbInformation, gstrAppName
                With PostToSyn
                    .Retrieved = True
                    .ReturnID = strNoteID
                End With
            Else
                MsgBox "The note was posted, but I could not retrieve its Synergi ID, please inform the DB Admin"
                PostToSyn.Retrieved = False
            End If
            
            Set uNode = Nothing
        End If

        Set oNode = Nothing
        Set oHttpReq = Nothing
        Set oXMLDoc = Nothing
    End If
End Function
 

KernelK

Registered User.
Local time
Yesterday, 20:50
Joined
Oct 3, 2006
Messages
173
To clarify a bit, it is after I run this portion of the code in the second part that the cached copy of the responseText is always returned:

Code:
        oHttpReq.Open "GET", strParam, False
        oHttpReq.Send

Also, the code works just fine the first time I run it. It is only after I attempt to run it after the initial run that I only get a cached copy.
 
Last edited:

KernelK

Registered User.
Local time
Yesterday, 20:50
Joined
Oct 3, 2006
Messages
173
I have it working now with using a POST method as opposed to using the GET method. If anyone can please answer me why GET is cached and POST is not would be extremely helpful still.
 

Users who are viewing this thread

Top Bottom