Access VBA Sending XML

jessss

Registered User.
Local time
Today, 11:31
Joined
Jan 17, 2010
Messages
29
Hi,


I am trying to create a module in access VBA which sends XML to a web address. The module I have created seems to be contecting to web address however I keep getting an error saying I am not authorised even through i am sending the username and password. I have been told I need the XML needs to be "Base64 encoded and appended to an 'Authorization: Basic' HTTP header" however I am not sure what this means, I have not used Base64 before. Can anyone tell me what it is and how I can use it in the module i have created below?


Code:
    Dim oWeb As MSXML2.XMLHTTP60  'Object from Microsoft XML v 5.0
    Dim bStatus As Boolean
    Dim wMsg As String
    Dim wResult As String
    Dim wPosi As Integer
    Dim wMaxWait As Integer
    Dim wError As String
    Dim WB_SERVICE_URL As String
    
    On Error GoTo Proc_ERROR
    
    bStatus = False
    
    WEB_SERVICE_URL = "https://test.test.com/v1.0/messagedispatcher"
    
    'Finish building the XML message
    wMsg = "<?xml version=""1.0"" encoding=""utf-8""?>"
    wMsg = wMsg & "<Messages><accountreference>EX0266361</accountreference>"
    wMsg = wMsg & "<message><to>" & number & "</to>"
    wMsg = wMsg & "<body" & City & "</body></message></messages>"
    
    
    Set myDom = New MSXML2.DOMDocument60
    myDom.LoadXml (wMsg)
    
    'Set up to post to our localhost server
    Set oWeb = New MSXML2.ServerXMLHTTP60
    
    APIUser = "user1"
    ApiKey = "password1"
    
    oWeb.Open "Post", WEB_SERVICE_URL, False, APIUser, ApiKey
    
    oWeb.setRequestHeader "Authorization", "application/xml"
    oWeb.send (myDom.XML)


Thank you


Jessica :D
 
Thank you for your reply and help. The link you sent was very helpful, however i found the link "https://codingislove.com/http-requests-excel-vba/". Using this i have managed to get my XML module working. However I ma still usnure of what Base64 does so if anyone could provide me with some information as to what it is/does i would appricate it
 
Extract from https://stackoverflow.com/questions/201479/what-is-base-64-encoding-used-for



some protocols may interpret your binary data as control characters (like a modem), or your binary data could be screwed up because the underlying protocol might think that you've entered a special character combination (like how FTP translates line endings)
<using asc data> you can be reasonably confident that your data's going to end up on the other side of the wire uncorrupted
 

Users who are viewing this thread

Back
Top Bottom