The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm=”SAP HANA Cloud Platform”‘.

In my line of work I quite often find myself connecting to Web Services to consume data, usually by SOAP or RESTful based services. They both have the good and bad points, the good points are that SOAP based exchanges usually come with a nice description of the contracts in the form of a WSDL file. However anything .net can be quite picky about how it digests these end points while a malformed or in-complete wsdl will quite happily be used by SoapUI or similar test suite, .net will struggle. Case in point if your bindings aren’t setup correctly, if you are not sure about the non-clemanture of WSDL files I suggest this as an old but good article to get you started.

I was getting the above error because I was not declaring my bindings properly, they weren’t mentioned at all in the WSDL so I suppose Visual Studio was behaving as expected, if they were they would have probably been declared in the app.config, I don’t like doing it there if I can help it though and prefer to do it programmatically. So, what I had to do was create bindings and past them with the configuration…..Something like this:

                Uri Address = new Uri("https://deadendpoint.com/pain");
                EndpointAddress EndPointAddr = new EndpointAddress(Address);
                //Create your binding this normally Basic for SOAP
                BasicHttpBinding Binding = new BasicHttpBinding();
                //If you have authenticate with HTTPS with username password we need to set Transport and Message Credential
                Binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
                Binding.Security.Mode = BasicHttpSecurityMode.Transport;
                Binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                //Instantiate Client with our binding and URI
                autoCreatedProxyClassClient ProxyClient = new autoCreatedProxyClassClient(Binding, EndPointAddr);
                //Specify Username-credential credentials
                ProxyClient.ClientCredentials.UserName.UserName = myUsername;
                ProxyClient.ClientCredentials.UserName.Password = myPassword;
                //Add request to field
                ProxyRequest.ProxyRequestField = ProxyDTRequest;

2 Replies to “The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm=”SAP HANA Cloud Platform”‘.”

  1. Hi, you do a great job. Thank you and proceed in the same way.
    you may help me.
    We faced with an issue that workflows cannot be launched. Each time we are receiving

    Request could not be dispatched.

    The Portal cannot connect to the middle tier using the web service interface. This failure prevents all portal scenarios from functioning correctly.

    The cause may be due to a missing or invalid server url, a downed server, or an invalid server firewall configuration.

    Ensure the portal configuration is present and points to the resource management service.

    But I can update any attributes and perform other changes, which does not trigger launching any workflows.

    Appreciate your help

    1. Sorry for the delay I don’t check comments very often, this error could be a number of things it basically means your portal cannot contact your MIM service. It’s usually incorrect SPN’s, incorrect Hostnames in Microsoft.ResourceManagement.Service.exe.config or they don’t match your SPN’s, incorrect host in web.config, firewalls etc. the list is endless

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux