From fc68f23a4889271888ca8ba3fde1f6f86d3f0fce Mon Sep 17 00:00:00 2001 From: Niels Basjes Date: Wed, 26 Apr 2017 11:21:39 +0200 Subject: [PATCH] HBASE-17962 Improve documentation on Rest interface Signed-off-by: Sean Busbey --- .../java/org/apache/hadoop/hbase/rest/RowResource.java | 8 +++++++- src/main/asciidoc/_chapters/external_apis.adoc | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java index 7be419089df..41b465f44c7 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java @@ -139,7 +139,13 @@ public class RowResource extends ResourceBase { if (!rowspec.hasColumns() || rowspec.getColumns().length > 1) { servlet.getMetrics().incrementFailedGetRequests(1); return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT) - .entity("Bad request: Either 0 or more than 1 columns specified." + CRLF).build(); + .entity("Bad request: Default 'GET' method only works if there is exactly 1 column " + + "in the row. Using the 'Accept' header with one of these formats lets you " + + "retrieve the entire row if it has multiple columns: " + + // Same as the @Produces list for the get method. + MIMETYPE_XML + ", " + MIMETYPE_JSON + ", " + + MIMETYPE_PROTOBUF + ", " + MIMETYPE_PROTOBUF_IETF + + CRLF).build(); } MultivaluedMap params = uriInfo.getQueryParameters(); try { diff --git a/src/main/asciidoc/_chapters/external_apis.adoc b/src/main/asciidoc/_chapters/external_apis.adoc index 556c4e04885..2f85461c0b1 100644 --- a/src/main/asciidoc/_chapters/external_apis.adoc +++ b/src/main/asciidoc/_chapters/external_apis.adoc @@ -225,14 +225,17 @@ creation or mutation, and `DELETE` for deletion. |Description |Example -|/_table_/_row_/_column:qualifier_/_timestamp_ +|/_table_/_row_ |GET -|Get the value of a single row. Values are Base-64 encoded. +|Get all columns of a single row. Values are Base-64 encoded. This requires the "Accept" request header with a type that can hold multiple columns (like xml, json or protobuf). |curl -vi -X GET \ -H "Accept: text/xml" \ "http://example.com:8000/users/row1" -curl -vi -X GET \ +|/_table_/_row_/_column:qualifier_/_timestamp_ +|GET +|Get the value of a single column. Values are Base-64 encoded. +|curl -vi -X GET \ -H "Accept: text/xml" \ "http://example.com:8000/users/row1/cf:a/1458586888395"