2

I am trying to post multiple columns / rows to my hbase cluster using the rest api. I can post 1 column at a time without trouble, but can't seem to get it to accept multiple columns / rows.

This works just fine

Data:

{
   "Row":{
      "@key":"www.somesite.com",
      "Cell":{
         "@column":"ColFam:Col1",
         "$":"someData"
      }
   }
}

Call:

curl -v -X PUT -H "Content-Type: application/json" --data '{"Row": { "@key":"www.somesite.com", "Cell": { "@column":"ColFam:Col1", "$":"someData" } } }' http://somesite.com:8080/TestTable/www.somesite.com/ColFam:Col1

According to the api, I should be able to post multiple rows / columns at the same time though.

Multi Column Data:

{
   "Row":
      {
         "key":"www.somesite.com",
         "Cell":[
            {
               "column":"ColFam:Col1",
               "$":"someData"
            },
            {
               "column":"ColFam:Col2",
               "$":"moreData"
            }
         ]
      }
}

Multi Row Data:

{
   "Row":[
      {
         "key":"www.somesite.com",
         "Cell":[
            {
               "column":"ColFam:Col1",
               "$":"someData"
            }
         ]
      },
      {
         "key":"www.someothersite.com",
         "Cell":[
            {
               "column":"ColFam:Col1",
               "$":"moreData"
            }
         ]
      }

   ]
}

I tried using the following urls:

http://somesite.com:8080/TestTable/www.somesite.com/ColFam:Col1
http://somesite.com:8080/TestTable/www.somesite.com/ColFam
http://somesite.com:8080/TestTable/www.somesite.com

To no avail. The documentation says to use false-row-key so I also tried:

http://somesite.com:8080/TestTable/false-row-key

Still no luck.

I get the same error every time:

upload completely sent off: 124 out of 124 bytes
HTTP/1.1 503 Service Unavailable

Any Ideas?

Eulalie367
  • 198
  • 4
  • 17
  • Could you please assist? I am trying to achieve the same thing with a PUT using multiple columns and getting a 200OK but the message body response is 'undefined'. what sort of response should I expect? – vbNewbie Jun 08 '17 at 19:00

2 Answers2

5

So all you have to do is base64 encode all the json values.

{
   "Row":[
      {
         "key":"d3d3LnNvbWVzaXRlLmNvbQ==",
         "Cell":[
            {
               "column":"QXV0aG9yczp0ZXN0MQ==",
               "$":"c29tZURhdGE="
            },
            {
               "column":"QXV0aG9yczp0ZXN0Mg==",
               "$":"bW9yZURhdGE="
            }
         ]
      }
   ]
}

This should have been obvious to me since the return values from the rest api are all base64 encoded.

Eulalie367
  • 198
  • 4
  • 17
  • It is unclear to me what was the endpoint URL after all. I tried the above payload without luck. Can anyone please post the right endpoint for the multi-row/col payload ? – gextra May 03 '15 at 13:11
1

JIRA HBASE-9435 has given this answer. Need to remove '@' and add '[]', the command like this:

curl -v -X PUT -H "Content-Type: application/json" --data '{"Row":[{"key":"www.somesite.com", "Cell": [{"column":"ColFam:Col1", "$":"someData"}]}]}' http://somesite.com:8080/TestTable/www.somesite.com/ColFam:Col1

also, values of "www.somesite.com", "ColFam:Col1", "someData" need to be base64 encode.

Chao Liu
  • 21
  • 2