Authentication problem


#1

I got the following error message when calling the API
The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm=“FlightXML2”’.

service.cs

[WebMethod]
public string TestMethod1()
{
    try
    {
        String strResult = "";

        FlightXML2SoapClient client = new FlightXML2SoapClient();
        client.ClientCredentials.UserName.UserName = "raymondlai";
        client.ClientCredentials.UserName.Password = "xxxxxxx";

        EnrouteStruct r = client.Enroute("KHOU", 5, "", 0);
        foreach (EnrouteFlightStruct e in r.enroute)
        {
            //Console.WriteLine(e.ident);
            strResult += e.ident + "\r\n";
        }

        //Console.WriteLine(client.Metar("KAUS"));
        strResult += client.Metar("KAUS");

        return strResult;
    }
    catch (Exception ex)
    {
        return "";
    }
}

Web.config

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
          <binding name="FlightXML2Soap"  >
            <security mode="Transport"  >
              <transport clientCredentialType="Basic" />
            </security>
          </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://flightxml.flightaware.com/soap/FlightXML2/op"
            binding="basicHttpBinding" bindingConfiguration="FlightXML2Soap"
            contract="FlightXML2.FlightXML2Soap" name="FlightXML2Soap" />
    </client>
</system.serviceModel>

#2

Can you confirm that you are using your API Key as your password and not your FlightAware account password?


#3

Thousand thanks for your help.

typo in my API Key.

Problem solved.