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.

working with whm api using c#.net

Discussion in 'cPanel Developers' started by sandeep p, Mar 19, 2016.

  1. sandeep p

    sandeep p Member

    Joined:
    Jun 25, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    bangalore
    cPanel Access Level:
    Root Administrator
    We tried to create an api interface using c#.net winforms but failed to login due 403 error
    code is attached for debugging

    Code:
      string url = "https://servername:2087/cpsess8074801816/xml-api/version";
    
      WebRequest wreq = WebRequest.Create(url);
    
      CredentialCache MyCredential = new CredentialCache();
      MyCredential.Add(new Uri("https://servername:2087/cpsess8074801816/xml-api/version"), "Basic", new NetworkCredential("root", "password"));
      wreq.Credentials = MyCredential;
       
      wreq.Timeout = 8000;
    
      WebResponse wres = wreq.GetResponse();
    
      if (((HttpWebResponse)wres).StatusDescription == "OK")
      {
      wres.Close();
      //  //Code if OK
      }
      else
      {
      wres.Close();
      //  //Code if not OK
      }
    
    
     
    #1 sandeep p, Mar 19, 2016
    Last edited by a moderator: Mar 19, 2016
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. sandeep p

    sandeep p Member

    Joined:
    Jun 25, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    bangalore
    cPanel Access Level:
    Root Administrator
    Not Log Entry was Found..

    App Gave Error as : The remote server returned an error: (403) Forbidden.
     
  4. sandeep p

    sandeep p Member

    Joined:
    Jun 25, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    bangalore
    cPanel Access Level:
    Root Administrator
    Entry was not found in log at /usr/local/cpanel/logs/login_log
    webrequest returned 403 error
     
  5. sandeep p

    sandeep p Member

    Joined:
    Jun 25, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    bangalore
    cPanel Access Level:
    Root Administrator
    issue resolved by creating additional layer to get session tokens
    thanks for all your support
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

Share This Page