AnsweredAssumed Answered

Unable to authenticate to UCP Director via REST API

Question asked by Erik Franz on Aug 3, 2016
Latest reply on Aug 5, 2016 by Erik Franz



I am facing the following problem: We run an UCP Director with version I am trying to use a simple REST GET command to connect to UCP Director. The code is written in .NET (see below). I always get a 401, unauthorized error. When I use a web browser on the same machine to connect to https://...../api/about it asks me for credentials and connects just fine. I have found no examples how to pass authentication information to UCP director in .NET.


Any help would be appreciated


            'to acceppt any SSL certificate

            ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack)


            Dim Method As String = "GET"

            Dim URL As String = ((tbURL.Text & "/api/about").Replace("//", "/").Replace(":/", "://"))

            Dim User As String = tbUser.Text

            Dim Password As String = tbPassword.Text


            Dim UCPClient As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(URL)


            UCPClient.Method = Method


            UCPClient.ContentType = "application/json"

            UCPClient.Accept = "application/json"

            UCPClient.ContentLength = 0


            Dim autorization = User & ":" & Password

            Dim binaryAuthorization As Byte() = Encoding.ASCII.GetBytes(autorization)

            autorization = Convert.ToBase64String(binaryAuthorization)

            autorization = "Basic " & autorization

            UCPClient.Headers.Add("Authorization", autorization)


            Dim wr As WebResponse = UCPClient.GetResponse

            Dim rd As StreamReader = New StreamReader(wr.GetResponseStream)