【发布时间】:2012-04-17 21:15:13
【问题描述】:
我正在使用 curl 通过 REST 访问 Hbase。我在将数据插入 Hbase 时遇到问题。我遵循了 Stargate 文档,但是当我遵循相同的语法时,它给了我 400/405 错误请求错误和不允许方法错误。我已经粘贴了下面的命令。请告诉我哪里出错了。
星际之门文档说
POST /<table>/<row>/<column> (:qualifier)?/<timestamp>
curl -H "Content-Type: text/xml" --data '[...]' http://localhost:8000/test/testrow/test:testcolumn
我的curl命令如下:
curl -H "Content-Type: text/xml" --data '[<CellSet><Row key="111"><Cell column="f1">xyz</Cell></Row></CellSet>]' http://localhost:8080/mytable/row/fam
这样做的正确方法是什么?因为这给了我 Bad request 错误。
另外,我在 Python 客户端中尝试了同样的操作。它给了我 ColumnFamilyNotFoundException。我正在从文件中读取要传递给星际之门服务器的 Xml 数据。代码如下。
url = 'http://localhost:8080/mytable/row/fam'
f = open('example.xml', 'r')
xmlData = f.read()
r = requests.post(url, data=xmlData, headers=headers)
example.xml 有以下内容:
<CellSet>
<Row key="111">
<Cell column="fam:column1">
xyz
</Cell>
</Row>
</CellSet>
【问题讨论】:
标签: python rest insert hbase stargate