# Http poller plugin automatically splits json response

**URL:** <https://discuss.elastic.co/t/http-poller-plugin-automatically-splits-json-response/277859>\
**Category:** Logstash\
**Created:** [July 5, 2021, 3:54pm UTC](https://discuss.elastic.co/t/http-poller-plugin-automatically-splits-json-response/277859 "2021-07-05T15:54:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjohnson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjohnson/32/91196_2.png) [@pjohnson](https://discuss.elastic.co/u/pjohnson)\
**Post date:** [July 5, 2021, 3:54pm UTC](https://discuss.elastic.co/t/http-poller-plugin-automatically-splits-json-response/277859/1 "2021-07-05T15:54:01Z")

</div>

I'm using the http\_poller plugin with an endpoint that returns a json array and then I'm processing the response in a ruby script. It seems like http\_poller is automatically splitting the body into separate events for each element in the response. I'm not using a split filter at all, and getting the error `Could not process event: undefined method `has_key?' for ["id", 5]:Array`. Is this expected/documented? Am I doing something wrong?

```auto
input {
    http_poller {
      urls => {
        poll_it => {
          method => get
          url => "http://endpoint/stuff"
        }
      }
      request_timeout => 60
      schedule => { every => "1m" }
      codec => "json"
      metadata_target => "poll_metadata"
      target => "body"
    }
}
filter {
  ruby {
    path => "/some/script.rb"
  }
}
output {
  pipeline {
    send_to => [someOtherPipeline]
  }
}

```

Script:

```auto
def filter(event)
  body = event.get("body")
  logger.error("test: ", {"value" => body})
  stuff = []
  for thing in body do
    if thing.has_key? "foo"
      stuff.push(thing["foo"])
    end
  end

  event.set("stuff", stuff.join(','))

  return [event]
end

```

---

<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:** [August 2, 2021, 3:54pm UTC](https://discuss.elastic.co/t/http-poller-plugin-automatically-splits-json-response/277859/2 "2021-08-02T15:54:48Z")

</div>

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