我正在尝试在向其发送json文件后从服务器获得确认响应。我无法看到以下问题。尝试连接服务器时,我一直遇到502错误。
感谢您的帮助!
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://stage-api.e-signlive.com/aws/rest/services/codejam");
post.setHeader("Authorization", "Basic Y29kZWphbTpBRkxpdGw0TEEyQWQx");
post.setHeader("Content-Type", "application/json");
File file = new File("test.json");
try{
post.setEntity(new FileEntity(file, "application/json"));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null){
System.out.println(line);
}
//System.out.println(response.getStatusLine().getStatusCode());
}
catch (IOException e){
e.printStackTrace();
}