Need code to read xml stream
Hi there,
I need someone to write a bit of code to read from a xml file, where its trying to suspend a service, I cannot be able to do this mysql my code is as follows:
As seen on this page: WHM XML-API using C# - Help Quote: NOTE: Remember that to get the XML-API result, you need to write some code to read the xml stream, because the lines above based on 'HttpWebResponse', will only return the connection result to the server.
I don't seem to know how write the code for the xml stream for it to be able to suspend the service, anyone who makes the sample code so I can just copy and paste will be much helpful!
```
string strURL = "https://cloud07.*************.co.uk:2087/cpsess2540182666/xml-api/suspendacct?api.version=1&user=******&reason=Nonpayment";
//string strURL = "https://cloud07.************.co.uk:2087";
WebRequest wreq = WebRequest.Create(strURL);
e.Channel.SendMessage("Process");
//Your credentials (the same you use to login on WHM panel)
CredentialCache MyCredential = new CredentialCache();
MyCredential.Add(new Uri("https://cloud07.***********.co.uk:2087"), "Basic", new NetworkCredential("********", "******"));
wreq.Credentials = MyCredential;
wreq.Timeout = 8000;
WebResponse wres = wreq.GetResponse();
if (((HttpWebResponse)wres).StatusDescription == "OK")
{
wres.Close(); //to free resources
//Code if OK
}
else
{
wres.Close(); //to free resources
//Code if not OK
}
```As seen on this page: WHM XML-API using C# - Help Quote: NOTE: Remember that to get the XML-API result, you need to write some code to read the xml stream, because the lines above based on 'HttpWebResponse', will only return the connection result to the server.
I don't seem to know how write the code for the xml stream for it to be able to suspend the service, anyone who makes the sample code so I can just copy and paste will be much helpful!
-
Hello, I'm not familiar enough with C# to provide you with custom code for your script, however here are a couple of threads you may find helpful: Get number of allowed addon domains via cpanel API cPanel login rejected with API through C# Thank you. 0
Please sign in to leave a comment.
Comments
1 comment