VijayKarthikeyan
VijayKarthikeyan

Reputation: 27

Curl command with delete option throws an exception

I have been working on Elastic search for a while and I have scenario to delete some indices in the elasticsearch.

As instructed in the ELK user guide, am trying to delete the indices using the CURL command in PowerShell on Windows Server 2012 R2

The command is given below

curl -X DELETE 'http://localhost:9200/logstash-2016.12.19/'

But when I give this command to delete in PowerShell, it throws the below error:

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'X'.
At line:1 char:6
+ curl -X DELETE 'http://10.242.244.170:9200/logstash-2016.12.19/'
+      ~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Can anyone help me solve this issue?

Upvotes: 2

Views: 1884

Answers (1)

Martin Brandl
Martin Brandl

Reputation: 58931

Curl is an alias for the Invoke-WebRequest cmdlet. It has no -X parameter but a -Method:

Invoke-WebRequest -Method Delete -Uri 'http://localhost:9200/logstash-2016.12.19/'

Upvotes: 5

Related Questions