0
我想通過將http POST方法應用於Google Vision API來發送json對象。我正在使用以下代碼:向Google Vision API發送請求
URL url = new URL("https://vision.googleapis.com/v1/images:annotate?key=<API-KEY>");
HttpsURLConnection http = (HttpsURLConnection)url.openConnection();
http.setDoOutput(true);
http.setRequestMethod("POST");
http.setRequestProperty("Content-Type", "application/json");
http.connect();
DataOutputStream wr = new DataOutputStream(http.getOutputStream());
wr.writeBytes(request.toString());
Log.v("JSON",request.toString());
wr.flush();
wr.close();
我收到一個錯誤的請求錯誤。需要幫助。我的JSON對象(請求)的格式如下:
{"imageContext":"",
"requests":"
{"image":
{"content":"..."},
"features":
{"type":"WEB DETECTION"}
{"maxResults":10}
}
}
什麼是你的錯誤的詳細信息的64位編碼的字符串?響應中是否有擴展的錯誤信息?你確定你已經正確認證了嗎?哦,你的JSON格式不正確,儘管這可能是一個剪切和粘貼錯誤。請發佈*精確* JSON。不應該''功能'是一個數組? –