I have access to an API. The API takes an XML post as input and then returns an XML response with the relevant data.
I want to
I don't have a programming background in excel but am comfortable with different web scripting languages, HTML, CSS, Javascript etc.
Any ideas?
The Excel request side can be handled with this VBA code.
Sub GetStuff()
Dim objXML As Object
Dim strData As String
Dim strResponse As String
strData = "Request"
Set objXML = CreateObject("MSXML2.XMLHTTP")
objXML.Open "POST", "www.example.com/api?" & strData, False
objXML.Send
strResponse = objXML.responsetext
MsgBox strResponse
End Sub
If you need to send your input xml as the message body here is how you can do it. You may need to add more or change the Request headers to get it to work for you.
Using the DOMDocument object make it easy to work with your xml documents.
Add a project references to;
Example:
Dim xmlInput As String
xmlInput = "<YourXmlRequest></YourXmlPayload>"
Dim oXmlHttp As MSXML2.XMLHTTP60
Set oXmlHttp = New MSXML2.XMLHTTP60
oXmlHttp.Open "POST", serviceURL, False, "UserName", "Password"
oXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlHttp.setRequestHeader "Connection", "Keep-Alive"
oXmlHttp.setRequestHeader "Accept-Language", "en"
oXmlHttp.send xmlInput
Debug.Print oXmlHttp.responseText
Dim oXmlReturn As MSXML2.DOMDocument60
Set oXmlReturn = New MSXML2.DOMDocument60
oXmlReturn.loadXML oXmlHttp.responseText
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With