2

I'm trying to get a confirmation response from a server after sending a json file to it. I can't see what the problem is with the following. I've been consistently getting a 502 error when attempting to connect to the server.

Thanks for the help!

    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();
    }
4

0 回答 0