Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following Java code is from RESTful client. ... ...

    Client client = Client.create();

    // get GET
    WebResource getWebResource = client.resource("http://your-host-ip:9292/images/detail");
    String s = getWebResource.get(String.class);
    System.out.println("response is " + s);
    JSONObject jsonObj = null;
    try {
        jsonObj = new JSONObject(s);
        JSONArray jsonArray = jsonObj.getJSONArray("images");
        int index = jsonArray.length();
        JSONObject imageObj = null;
        for (int i = 0; i < index; i++) {
            imageObj = jsonArray.getJSONObject(i);
            String imageName = imageObj.getString("name");
            System.out.println("name is " + imageName);
            Long imageSize = imageObj.getLong("size");
            System.out.println("image size is " + imageSize.toString());

        JSONObject newImage = jsonArray.getJSONObject(0);
    } catch (JSONException e) {
        // TODO Auto-generated catch block

    // test DELETE
    WebResource deleteWebResource = client.resource("http://your-host-ip:9292/images/3");

The above GET and DELETE method seem working. The output of GET is only Meta data. Where is the real image? I could not find details description from Glance documentation. I can not get PUT or POST to work and I am getting HTTP error 400 and 404. Do you have documentation to describe the RESTful interface? If you can provide sample code (Java), that would be great!