title: Bing Search API Azure Marketplace Authentication (Delphi + Indy)
body: <p>Can anyone point in the right direction? I'm trying to perform web searches sung the new Bing API, but with the below code I keep getting "HTTP/1.1 400 Bad Request". The same request works well under the browser (leaving username blank and providing the key under password inside the   prompt box).</p>
  
  <pre><code>var
    IdHTTP1 : TIdHTTP;
    uri : string;
    myIOhandler : TIdSSLIOHandlerSocketOpenSSL;
  begin
    myIOhandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    with myIOhandler do
    begin
        SSLOptions.Method := sslvTLSv1;
        SSLOptions.Mode := sslmUnassigned;
        SSLOptions.VerifyMode := [];
        SSLOptions.VerifyDepth := 0;
        host := '';
    end;
  
    IdHTTP1:= TIdHTTP.Create(nil);
    IdHTTP1.Request.UserAgent:= 'Mozilla/3.0 (compatible; IndyLibrary)';
    IdHTTP1.Request.Accept := 'text/javascript';
    IdHTTP1.Request.ContentType := 'application/json';
    IdHTTP1.Request.ContentEncoding := 'utf-8';
  
    IdHTTP1.HandleRedirects:= True;
    IdHTTP1.ConnectTimeout:= 10000;
    IdHTTP1.ReadTimeout:= 10000;
    IdHTTP1.Request.CacheControl := 'no-cache';
    IdHTTP1.Request.BasicAuthentication:= True;
    IdHTTP1.Request.Authentication:= TIdBasicAuthentication.Create;
    IdHTTP1.Request.Authentication.Username:= '';
    IdHTTP1.Request.Authentication.Password:= APIKey;//Encode64(APIKey);//Encode64(APIKey+':'+APIKey)
    IdHTTP1.IOHandler:= myIOHandler;
  
    uri:= 'https://api.datamarket.azure.com/Bing/SearchWeb/Web?'+
            'Query=%27'+ query_text +'%27&amp;$format=JSON&amp;$top=50&amp;$skip=0';
    s:= IdHTTP1.Get(uri);  
  </code></pre>
  
  <p>MS documentation is very poor.</p>