【发布时间】:2018-06-16 12:48:10
【问题描述】:
我正在尝试使用 Gson 开发 Java 应用程序,以使用外部 api 来获取简单的文本翻译。下面是代码和输出。我在 HTTP 发布 URL 中的 API 密钥的指定位置使用了我的 API 密钥 你能帮我搞定这个工作吗? 非常感谢。
// 代码
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("URL");
StringEntity input = new StringEntity(json);
input.setContentType("application/json");
post.setEntity(input);
HttpResponse response = client.execute(post);
System.out.println(response.getStatusLine());
//输出
HTTP/1.1 415 Unsupported Media Type
【问题讨论】:
标签: java json gson translators