0

我正在尝试从 Xamarin.Forms 应用程序调用 Google Vision REST API。我有以下代码: -

 private async void SendToGoogle(MediaFile file)
    {
        using (HttpClient client = new HttpClient())
        {
            string uri = "https://vision.googleapis.com/v1/images:annotate?key=API_KEY";
            HttpResponseMessage response;

            var stream = file.GetStream();
            using (var content = new StreamContent(stream))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                content.Headers.ContentLength = stream.Length;
                response = await client.PostAsync(uri, content);

                var resp = await response.Content.ReadAsStringAsync();
            }
        }
    }

但这给我返回了一条400错误消息:

收到无效的 JSON 有效负载。期望值。

4

0 回答 0