The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need code to read xml stream

Discussion in 'cPanel Developers' started by alexr03, Jul 19, 2016.

  1. alexr03

    alexr03 Registered

    Joined:
    Jul 19, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    UK
    cPanel Access Level:
    Reseller Owner
    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:

    Code:
    ```
                    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:
    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!
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page