0 Replies Latest reply on May 5, 2016 1:06 PM by rpbarron

    I would like to use the RestAPI using .Net C#


      I am having issue calling the RestAPi from C# using HttpWebRequest; I keep getting a "The remote server returned an error: (401) Unauthorized."; I think this is because when we access our community on Jives; we don't have to sign; but already authenticated through our single sign on site then redirect to our community, below is the code used








      WebProxy oProxy = new WebProxy("xxxxxxx.com", 80);

      CredentialCache myCache = new CredentialCache();
      string jiveURL = "https://xxxxx.jiveon.com";


      NetworkCredential myCredentials = new NetworkCredential("xxxxx", "xxxxxx", "xxx");
      myCache.Add(new Uri("https://xxxx.jiveon.com"), "Basic", myCredentials);


      var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://xxxx.jiveon.com/api/core/v3/places/99999/contents?filter=type(document)");
      httpWebRequest.ContentType = "application/json";
      httpWebRequest.Accept = "*/*";
      httpWebRequest.Method = "GET";
      httpWebRequest.Proxy = oProxy;
      httpWebRequest.Proxy.Credentials = myCredentials;
      httpWebRequest.Credentials = CredentialCache.DefaultCredentials;

      string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes("xxxxxxx" + ":" + "xxxxxx*"));
      httpWebRequest.Headers.Add("Authorization", auth);
      ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);