使用Invoke-Webrequest的无效正文

时间:2018-05-10 14:42:41

标签: powershell httpwebrequest

我正在尝试使用以下指南发布到Wazuh服务器: https://documentation.wazuh.com/3.x/user-manual/api/reference.html#add-agent

这是CURL的等价物:

curl -u foo:bar -k -X POST -d '{"name":"NewHost","ip":"10.0.0.9"}' -H 'Content-Type:application/json' "https://127.0.0.1:55000/agents?pretty"

这就是我使用Powershell的原因:

Invoke-WebRequest -Body "{name:'newhost',ip:'10.0.0.9'}" -Uri "http://$($WAZUHSERVER):55000/agents?pretty" -Method Post -Credential $MyCredential -ContentType 'application/json'

我一直收到“无效的请求正文”。 我尝试用哈希表交替。没有骰子。我应该提一下,我没有配置SSL,因此该部分无关紧要。

0 个答案:

没有答案
相关问题