2017-07-06 95 views
0

我们必须安装apache钻1.10,并实施了“普通身份验证”。经过应用验证机制,无法通过REST来创建存储插件API.But,它正在我们面前应用认证。 这里我们正努力创造通过REST API调用存储插件..阿帕奇钻REST API认证

Please help me how can we execute REST by using some user credential. 
    http://172.18.128.12:8047/storage/hdfs_test.json 
    { 
    "name": "hdfs_test", 
    "config": 
    { 
    "type" : "file", 
    "enabled" : true, 
    "connection" : "hdfs://<IP>:8020/", 
    "workspaces" : { 
    "root" : { 
    "location" : "/tmp", 
    "writable" : true, 
    "defaultInputFormat" : null 
    } 
    }, 
    "formats" : { 
    "json" : { 
    "type" : "json" 
    } 
    } 
    } 
    } 

    below is the error 
    Invalid username/password credentials. 

请帮助我们,如果有人已经面临这个问题。 在此先感谢。

+0

修复第一段。 – phd

回答

2

你可以尝试以下。更换的“https”以“http”如果HTTPS未启用。

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -k -c cookies.txt -s -d "j_username=<USER-NAME>" -d "j_password=<PASSWORD>" https://localhost:8047/j_security_check 

下面是启用配置单元存储插件的示例命令。根据您的环境修改参数值。

curl -k -b cookies.txt -v -X POST -H "Content-Type: application/json" -d '{"name":"hive", "config": {"type": "hive", "enabled": true, "configProps" : { "hive.metastore.uris" : "thrift://lab-node1:9083", "javax.jdo.option.ConnectionURL" : "jdbc:mysql://lab-node1:3306/hive?createDatabaseIfNotExist=true", "hive.metastore.warehouse.dir" : "/user/hive/warehouse", "hive.metastore.sasl.enabled": "true", "hive.server2.enable.doAs": "true" } }}' https://localhost:8047/storage/hive_test.json 
+0

感谢您指出的修正! – InfamousCoconut

0

下面是使用curl通过钻REST API查询JSON文件的另一个例子:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -k -c cookies.txt -s -d "j_username=<USER-NAME>" -d "j_password=<PASSWORD>" https://localhost:8047/j_security_check 

curl -k -b cookies.txt -v -X POST -H "Content-Type: application/json" -d '{"queryType":"SQL", "query": "SELECT * FROM dfs.`/tmp/data.json` limit 2"}' https://localhost:8047/query.json