Ambari API POST抱怨CSRF保护

roy*_*roy 0 hdinsight hortonworks-data-platform ambari

我正在尝试使用以下命令通过Ambari API设置hbase属性

curl -u "admin:admin" -i -X POST -d '{"type": "hbase-site", "tag": "version3", "properties" : {"hbase.regionserver.global.memstore.size" : "0.6"}}' https://abct.net/api/v1/clusters/xyz/configurations

但是不断出现错误

HTTP/1.1 400 Bad Request
Content-Length: 107
Content-Type: text/plain
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Microsoft-IIS/8.5
x-ms-hdi-active: 10.8.18.29
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
X-Powered-By: ARR/3.0
Set-Cookie: AMBARISESSIONID=2e8ortl32j1p7zdjatigdgvg;Path=/;HttpOnly; path=/; secure
X-Powered-By: ASP.NET
Date: Mon, 12 Sep 2016 18:19:38 GMT

{
  "status" : 400,
  "message" : "CSRF protection is turned on. X-Requested-By HTTP header is required."
}
Run Code Online (Sandbox Code Playgroud)

这里缺少什么?

Bri*_*rig 5

事实证明,除了GET请求外,您还必须将请求标头添加到请求中。

您可以使用添加标题

curl --header "X-Requested-By: my_computer_name"
Run Code Online (Sandbox Code Playgroud)

要么

您可以禁用此功能