Search code examples
pythonexcelxml-rpcconfluencevba

Update my wiki from Excel macro


I'm currently able to update my wiki page using script like follows:

import sys
from xmlrpclib import Server
s = Server("https://my.wiki.root/rpc/xmlrpc")
token = s.confluence2.login("user", "passwd")
page = s.confluence2.getPage(token, "WIKI SPACE", "page")

page["content"] = '<xml content>'
s.confluence2.storePage(token, page)

[credits to Atlassian's Confluence XML-RPC and SOAP APIs]

But I can't install Python (I don't know much about this great language) on my PC, and I wondered if I could do it (nearly) as easily with Excel. I'm trying this:

Sub updatePage()    
    Dim URL As String, myXML As String
    Dim xmlHttp As Variant    
    Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")

    myXML = "<my xml>"

    URL = "https://my.wiki.root/rpc/xmlrpc"
    xmlHttp.Open "POST", URL, False

    #' I specify my content type
    xmlHttp.SetRequestHeader "Content-Type", "text/xml"

    #' Here I'm less and less sure
    xmlHttp.send "pageId=248091993&editorFormat=" + myXML

    #' This is void...
    MsgBox xmlHttp.responseText

End Sub

I just get nothing in responseText. I don't know where to look.

  • How can I "emulate" these python commands (without having to install eerie softs like pyxll)? If I've no solution, I'll (easily?) fix something to send commands via to a server where python can run... But I'm sure it can be done with Excel.
  • If I knew how I could get this s structure returned in python with Server("xmlrpc URL") I would've won! But what is it? How do I get it with Excel?

Solution

  • You should try to login in your VBA code.

    You do it in the Python, but why don't you in th VBA?

    e.g.

    URL = "my.wiki.root/rpc/xmlrpc?id=user&pwd=passwd"; 
    

    This should fix your issue.