receiving 401 Unauthorized on webservice calls that used to work.

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
  • (Edited)
Built a c# application to automate the invocation of specific reports and download the results to CSV files for integration to a data warehouse.
As of April 1st, everything was working fine.
As of April 12th (I haven;t touched it in between)  we can no longer access the services, we get 401 Unauthorized back from the server.  

I validated in Replicon that my user still has the administrator role.

Here is how we have built and called  the request.

  var url = "";            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.Accept = "application/json";
            String username = "XXX\\"+user;
            String password = passwd;
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("UTF-8").GetBytes(username + ":" + password));
            request.Headers.Add("Authorization", "Basic "+encoded);
requestObject.reportUri = "urn:replicon-tenant:xxx-gen3:report:f1e9258e-e60c-4f47-44f9-1085ed4f0ea7";
            requestObject.filterValues = filterValues;
            requestObject.outputFormatUri = "urn:replicon:report-output-format-option:csv";

       //Serialize and submit request
            var requestBody = JsonConvert.SerializeObject(requestObject);
            request.ContentLength = requestBody.Length;
            var streamWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
            //get the Response
            var response = request.GetResponse();    
            var streamReader = new System.IO.StreamReader(response.GetResponseStream());
            var responseContent = streamReader.ReadToEnd().Trim();  
Is Basic Auth not allowed anymore?

Here is the response 
Unhandled Exception: System.Net.WebException: The remote server returned an error: (401) Unauthorized
   at System.Net.HttpWebRequest.GetResponse()
Photo of Paul Saker

Paul Saker

  • 4 Posts
  • 1 Reply Like

Posted 4 years ago

  • 1
Photo of Aashnee Kamboj

Aashnee Kamboj

  • 1657 Posts
  • 116 Reply Likes
Hi Paul,

Thank you for using Replicon Community!

I will have to check this internally. There should not be a basic auth issue. I will confirm and get back to you

Photo of Paul Saker

Paul Saker

  • 4 Posts
  • 1 Reply Like
Ah, my bad.
I was not doing a lookup to capture the URL our companies service was currently deployed on.
For instance, some days we are na2, some days we are na8, na6 etc.
I will put some code in to call for the URL before building it for the rest of the process using

Thanks for looking into it anyway.