Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有Apache库的HttpPost Java_Java_Json_Apache_Http_Http Headers - Fatal编程技术网

带有Apache库的HttpPost Java

带有Apache库的HttpPost Java,java,json,apache,http,http-headers,Java,Json,Apache,Http,Http Headers,我试图在向服务器发送json文件后从服务器获取确认响应。我看不出下面的问题是什么。我一直在尝试连接到服务器时遇到502错误 谢谢你的帮助 HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("https://stage-api.e-signlive.com/aws/rest/services/codejam"); post.setHeader("Authorization",

我试图在向服务器发送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();
    }

502错误代码是服务器错误(“坏网关”)。看见这通常意味着服务器上出现崩溃,但这是由于内部错误,而不是您的请求有问题。您可能希望联系e-Sign Live支持,查看他们的服务器是否已启动。