0
votes

I'm trying to use the hbase rest API. I've read the docs here (http://wiki.apache.org/hadoop/Hbase/Stargate), but they seem to be incomplete (doesn't cover json) and out of date.

I've also run across this gist, which is mostly what I'm going off of.

Here is the (insert) request I'm trying to send:

  • URI: http://server:8070/table/row1/data
  • Headers:
    • Content-Type : application/json
    • Accept : application/json
  • HTTP verb - POST

and the json payload (where key, column, and $ are all base64 encoded values):

{
    "Row": {

        "key": "NjQ=",
        "Cell": [{
            "column": "NjQ=",
            "$": "NjQ="
        }]
    }
}

Here is the error I get:

Error 500 Can not deserialize instance of java.util.List out of START_OBJECT token
 at [Source: org.mortbay.jetty.HttpParser$Input@3da0b822; line: 2, column: 5]
 (through reference chain: org.apache.hadoop.hbase.rest.model.CellSetModel["Row"])

The error seems to suggest that there is something that should be an array and isn't. I've tried putting square brackets just about everywhere, and I can't get it to do anything other than change the nature of the error message slightly.

I had a look through the source code and that seems to suggest that the placement for the square brackets that I have is correct. However, as far as I can tell the entire request looks to be correct. I'm not very fluent in Java though, so maybe I'm missing something.

What is the proper JSON syntax for inserting a record with the hbase rest gateway?

1

1 Answers

0
votes

This is now the correct format:

{
    "Row": [{

        "key": "NjQ=",
        "Cell": [{
            "column": "NjQ=",
            "$": "NjQ="
        }]
    }]
}

Where:

  • key - is the row key
  • column - is the column name
  • $ - is the data that you are storing in the given table, column, and row.