static async void RunClient() { try { Console.WriteLine("Translating English phrase {0} (might take some seconds)...", "Hello World"); // Create client and insert a message handler that obtains an Azure Marketplace Access Token in the message path HttpClient client = new HttpClient(new AccessTokenMessageHandler(new HttpClientHandler())); // Create BING translate options data which we send along with the HTTP request as part of the HTTP request body. // TranslateOptions is a type provided by BING translation service. TranslateOptions options = new TranslateOptions("", "defaultUser"); // Send asynchronous request to BING translation API MediaTypeFormatter xmlFormatter = new XmlMediaTypeFormatter { UseXmlSerializer = true }; HttpResponseMessage response = await client.PostAsync<TranslateOptions>(_address, options, xmlFormatter); // Check that response was successful or throw exception response.EnsureSuccessStatusCode(); // Read response asynchronously as GetTranslationsResponse which is a type defined by BING translation service GetTranslationsResponse translation = await response.Content.ReadAsAsync<GetTranslationsResponse>(new[] { xmlFormatter }); Console.WriteLine(); Console.WriteLine("...{0}", translation.Translations[0].TranslatedText); } catch (Exception e) { Console.WriteLine("Request caused exception: {0}", e.Message); } }