I have inherited a API which gives a Visual Basic example of how to call the API which is below:
Dim sPost As String
Dim sAction As String
Dim sXMLData As String
Dim sHTTPHeaders As String
sPost = "POST"
sAction = "http://MyHost/1/XmlService"
sXMLData = "<xml ..> <request …….. /></xml>"
sHTTPHeaders = "Content-type: text/xml"
Inet1.Execute sAction, sPost, sXMLData, sHTTPHeaders
I am familar with using HttpWebRequest and have no issue setting the content type, method etc but I am not sure how to set the sXMLData - which property of my HttpWebRequest would I set?
Thanks in Advance.
It looks like you'd want to write that XML data to the request body. To do that, you normally create a StreamWriter using HttpWebRequest.GetRequestStream():
// HttpWebRequest request;
// string sXmlData;
using (StreamWriter sw = new StreamWriter(request.GetRequestStream()))
{
sw.Write(sXmlData);
}
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