# Translate a CURL command into a HTTP filter request

**URL:** https://discuss.elastic.co/t/translate-a-curl-command-into-a-http-filter-request/313403
**Category:** Logstash
**Created:** [September 1, 2022, 1:51am UTC](https://discuss.elastic.co/t/translate-a-curl-command-into-a-http-filter-request/313403 "2022-09-01T01:51:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ygal\_Mizrachi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ygal_mizrachi/32/103492_2.png) [@Ygal\_Mizrachi](https://discuss.elastic.co/u/Ygal_Mizrachi)
#### Post date: [September 1, 2022, 1:51am UTC](https://discuss.elastic.co/t/translate-a-curl-command-into-a-http-filter-request/313403/1 "2022-09-01T01:51:42Z")

</div>

Hello i need some help translating this CURL request into a http filter syntax

```auto
curl -k -u username:password -X POST 'https://192.168.88.1/rest/tool/flood-ping' \--data '{"address":"192.168.88.223","count":"12","interval":"20ms"}' \ 
  -H "content-type: application/json"

```

This command WORKS as it returns this response:

```auto
[{".section":"0","avg-rtt":"1","max-rtt":"1","min-rtt":"1","received":"1","sent":"2"},{".section":"1","avg-rtt":"1","max-rtt":"1","min-rtt":"1","received":"12","sent":"12"}]% 

```

Wich is the expected one.

As of now i have tried this configuration of the http filter plugin.

```auto
input {
    stdin {
        
    }
}
filter {
    http {
        url => "https://%{message}/rest/tool/flood-ping"
        user => "username"
        password => "password"
        headers => {
            "Content-Type" => "application/json"
        }
        verb => "POST"
        ssl_verification_mode => "none"
        query => {
            "address" => "192.168.88.223"
            "interval" => "20ms"
            "count" => "120"
        }
        target_body => "respt"
        
    }
}

output {
    
    stdout {
        
    }
}

```

But im getting this message:

```auto
[ERROR] 2022-08-31 21:26:17.884 [[main]>worker0] http - error during HTTP request {:url=>"https://192.168.88.1/rest/tool/flood-ping", :code=>400, :response=>"{\"detail\":\"missing values (5)\",\"error\":400,\"message\":\"Bad Request\"}"}
{
      "@version" => "1",
    "@timestamp" => 2022-09-01T01:26:15.342475Z,
         "event" => {
        "original" => "192.168.88.1"
    },
       "message" => "192.168.88.1",
          "host" => {
        "hostname" => "pragma"
    },
          "tags" => [
        [0] "_httprequestfailure"
    ]
}

```

Thanks in advance for any help that can be provided.

---

<div class="post-metadata">

### Author: ![jsvd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsvd/32/6203_2.png) [@jsvd](https://discuss.elastic.co/u/jsvd)
#### Post date: [September 1, 2022, 1:30pm UTC](https://discuss.elastic.co/t/translate-a-curl-command-into-a-http-filter-request/313403/2 "2022-09-01T13:30:53Z")

</div>

> [@Ygal\_Mizrachi](#):
>
> ```auto
> query => {
> "address" => "192.168.88.223"
> "interval" => "20ms"
> "count" => "120"
> }
> 
> ```

You want to use "body" setting instead of "query". the "query" setting places the values in the query string (e.g. `http://ip:port?key1=value1&key2=value2`):

```auto
        body => {
            "address" => "192.168.88.223"
            "interval" => "20ms"
            "count" => "120"
        }
        body_format => json

```

This will create an HTTP request like so:

```auto
POST /rest/tool/flood-ping HTTP/1.1
Connection: Keep-Alive
Content-Type: application/json
Content-Length: 60
Host: localhost:4444
User-Agent: Manticore 0.9.1
Accept-Encoding: gzip,deflate
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

{"address":"192.168.88.223","count":"120","interval":"20ms"}

```

---

<div class="post-metadata">

### Author: ![Ygal\_Mizrachi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ygal_mizrachi/32/103492_2.png) [@Ygal\_Mizrachi](https://discuss.elastic.co/u/Ygal_Mizrachi)
#### Post date: [September 1, 2022, 10:28pm UTC](https://discuss.elastic.co/t/translate-a-curl-command-into-a-http-filter-request/313403/3 "2022-09-01T22:28:10Z")

</div>

Thank you so much for your help. This helped me a lot. I hope this also helps someone else

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 29, 2022, 10:28pm UTC](https://discuss.elastic.co/t/translate-a-curl-command-into-a-http-filter-request/313403/4 "2022-09-29T22:28:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
