2 Replies Latest reply on Jul 20, 2012 3:32 AM by hec.ravi

    Rest V2 401 Unauthorized Response

      What am I doing wrong? I am able to have REST GETs working but now I am trying to setup a POST and I keep getting 401 Unauthorized. We have Jive hosted version 5 and I am trying to use Rest Core V2 API.

       

      Some simple C# code I am trying to see if I can authenticate so that I can post a document.

       

                // Create the web request  
                  HttpWebRequest request = WebRequest.Create("https://context/api/core/v2/spaces/2059/documents") as HttpWebRequest;  
                  // Add authentication to request  
                  request.Credentials = new NetworkCredential("myUser", "myPassword");  
      
                  // Get response  
                  using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)  
      

       

      of course "context" is my url for the site and myUser/myPassword is the user that I granted access to the REST Api

       

      Questions:

      1) Do I have the URL correct? I also tried just http://context/api/core/v2

      2) Do I need to get Jive to setup some sort of authetication between where these request are coming from (doubtful). I enabled Core Web Services in the admin UI

      3) Do I have the C# code wrong?

        • Re: Rest V2 401 Unauthorized Response

          Ok so using Firefiok Rest tool I was able to see that It encyrpts the userName and password and adds it to the headers. (It would be nice to know what it is doing).

           

          BUT..I am now getting Status Code 415 Unsupported Media Type

           

          I tried adding Content-Type: application/json and Accept: application/json

           

          with a body of

          {

            "html" : "This is my comment"

          }

           

          Is there a complete example of V2 Rest API (all searches yield Old School RPC way of doing things) that shows what exact headres to send as well as what a request body looks like for a post (like post of a document or discussion)??