locked
Posting XML to a Restful service

    Question

  • Hi,

    I'm trying to consume a restful service that needs XML posted to form the query.  XML is then returned with the query results.

    I've gotten as far making a connection to the web service using a custom formula :

    = Xml.Tables(Web.Contents("https://webservice"),[Content="<?xml version='1.0' encoding='UTF-8'?><call method='methodname'><credentials login='username' password='password'></credentials></call>"])

    The web service is returning an error telling me the XML I post is invalid.

    I know the XML is valid as I can run it successfully from Excel VBA using the MSXML library. I avoided the need to escape characters by using ' instead of ".   Is there any additional escaping I should be doing with Data Explorer?

    Thanks in advance.

    Friday, June 14, 2013 1:00 PM

Answers

  • I sorted this problem after reading the helpful post from Chris Webb here :

    http://social.msdn.microsoft.com/Forums/en-US/dataexplorer/thread/61ece381-49b9-48e5-a70b-5e35016c28ac

    I amended the query to :

    = Xml.Tables(
    Web.Contents("https://webservice",[Content=Text.ToBinary("<?xml version='1.0' encoding='UTF-8'?><call method='methodname'><credentials login='login' password='password'></credentials></call>")]))

    The mistake was the ) in the wrong place.  I also had to use the Text.ToBinary() - thanks Chris!.     I also had to use anonymous credentials when using the content properties.

    Works a treat.

    The use case I have in mind is to using DE as a self service Data Integration tool for combining cloud and on-premise data sources.   I have sourced the cloud data (the hard part!) so it's looking like I'm on the way to getting what I've been looking for.

    Thanks Microsoft Research and the DE devs.

    • Marked as answer by Lee Hawthorn Friday, June 14, 2013 1:24 PM
    Friday, June 14, 2013 1:24 PM