AnsweredAssumed Answered

Getting Object Information

Question asked by Roguen Keller Employee on Mar 22, 2017
Latest reply on Mar 24, 2017 by Roguen Keller

I'm executing the following code from our samples in Java:


    public static void head(HttpClient client, String auth) throws IOException{

        //specify namespace URL - eg.

        String url = "http://example-namespace.example-tenant.example-domain/rest/examples/world.txt";


        HttpHead request = new HttpHead(url);


        //add authorization header for user(base64) "exampleuser" with password(md5) "password"

        request.addHeader(HCPAuthHeaderKey, auth);


        //execute the request

        HttpResponse response = client.execute(request);


        //print response status to console

        System.out.println("Response Code : "

                + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());


        //get response content

        BufferedReader rd = new BufferedReader(

                new InputStreamReader(response.getEntity().getContent()));


        //print response content to console

        StringBuffer result = new StringBuffer();

        String line = "";

        while ((line = rd.readLine()) != null) {





I get a 200 response from this execution for the initial status code, but then I get a null pointer when I try to read the entity content a bit later.

The file does exist here and can be retrieved, but I'm not getting the expected system metadata repsonse I would expect which looks like this:


HTTP/1.1 200 OK
X-HCP-Time: 1259584200
Content-Type: text/plain
Content-Length: 12
X-HCP-Type: object
X-HCP-Size: 12
X-HCP-Hash: SHA-256 D2A84F4B8B6... X-HCP-VersionId: 80205544854849 X-HCP-IngestTime: 1258469614 X-HCP-RetentionClass: X-HCP-RetentionString: Deletion Allowed X-HCP-Retention: 0
X-HCP-RetentionHold: false
X-HCP-Shred: false
X-HCP-Index: false X-HCP-Custom-Metadata: false