I'm trying to post data to a restful web service that accepts XML with the request.
With the code below I can connect to the service but my XML data is not being recognised correctly by the service. According to the API doc the xml needs to be encoded from text to binary. I've read the RCurl docs but can't see how to do this.
url<-"https://serivce"
myheader=c(Connection="close",
'Content-Type' = "application/xml",
'Content-length' =nchar(xml_data))
opts <- list(
proxy = "proxy",
proxyusername = "uname",
proxypassword = "password",
proxyport = port,
ssl.verifypeer = FALSE
)
data = getURL(url = url,
postfields=xml_data,
.opts = opts,
httpheader=myheader,
verbose=TRUE)
Additional info
I wrote the xml data to an XML file with
xmlfile <- "myfile.xml"
saveXML(xmlTreeParse(xml_data,useInternalNodes=T),xmlfile)
How can I post this xml to the URL with RCurl?