What is wrong with this delphi code for Bing translator API?

396 views Asked by At

I am using the follow delphi code:

 clHttp1.Request.Header.ContentType := 'application/x-www-form-urlencoded';
 try
    AccountKey:=Account;
    clHttp1.Request.AddFormField('client_id',clientValue);
    clHttp1.Request.AddFormField('client_secret',AccountKey);
    clHttp1.Request.Header.Authorization:='Basic ' + Encode64(AccountKey + ':' + AccountKey);
    clHttp1.Post('https://api.datamarket.azure.com/Bing/MicrosoftTranslator/v1/Translate?Text=%27developer%27&To=%27es%27&From=%27en%27', value);
except
      on e: Exception do
        ShowMessage(e.Message);
end;

And always receive error "the authorization type you provided is not supported. only basic and oauth are supported" with response

HTTP/1.1 401 The authorization type you provided is not supported.  Only Basic and OAuth are supported
Server: Microsoft-IIS/8.0
X-Content-Type-Options: nosniff
WWW-Authenticate: Basic Realm=""
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Allow-Headers: Authorization, DataServiceVersion, MaxDataServiceVersion
Access-Control-Expose-Headers: DataServiceVersion, MaxDataServiceVersion
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Max-Age: 604800
Date: Wed, 19 Nov 2014 09:40:24 GMT
Content-Length: 91

What I am doing wrong?

0

There are 0 answers