Unauthorized error while trying to connect to Version One via REST in C#

39 views
Skip to first unread message

Shreyance

unread,
Apr 1, 2016, 10:08:57 AM4/1/16
to VersionOne-users
Hello,

We are trying to access Version One via REST in C# using the HTTPWebRequest class.
We are aware that there are VersionOne .NET SDK available for download, we are having problem with using the SDK due to some environment issues, have already raised a support ticket for the same. But we want an alternate method as well as a backup, should the issue not be resolved.

I am pretty sure that the credentials I provided is correct but not sure why am i getting this Unauthorized error. We are using Integrated Authentication on our Version One instance.
Jotting down the code below, can somebody help us out ?

This is a simple GET Query to get member details.


            string Result;
            HttpWebResponse response;
            HttpWebRequest request = WebRequest.Create(@"http://v1/VersionOne/rest-1.v1/Data/Member/20") as HttpWebRequest;
            request.ContentType = "application/xml";
            request.Method = "GET";
            string base64Credentials = EncodedCredentials;
            request.Headers.Add("Authorization", "Basic " + base64Credentials);

            response = request.GetResponse() as HttpWebResponse;   // Getting error here

            StreamReader reader = new StreamReader(response.GetResponseStream());
            Result = reader.ReadToEnd();
            response.Close();


Thanks,
Shreyance
Reply all
Reply to author
Forward
0 new messages