none
I am Having an error (Bad Request) Project Oxford Face emotion API (REST) with C# RRS feed

  • Question

  • public static async void Face_EmotionFaceRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            //client.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "******");

            var uri = "https://api.projectoxford.ai/emotion/v1.0/recognize";
            HttpResponseMessage response;

            // Request body
            string imageUrl = "http://media5.picsearch.com/is?u4TabkH7FhghH4zpJ6empA68aAqM8SFng2TOrQS4Z4&height=319";
            string requestdata = "{\"url\":" + imageUrl + "}";
            byte[] byteData = Encoding.UTF8.GetBytes(requestdata);

            using (var content = new ByteArrayContent(byteData))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                response = await client.PostAsync(uri, content);
            }
        }
    Tuesday, December 15, 2015 2:02 PM