# Call recursively an API

**URL:** https://discuss.elastic.co/t/call-recursively-an-api/289284
**Category:** Logstash
**Created:** [November 16, 2021, 9:06am UTC](https://discuss.elastic.co/t/call-recursively-an-api/289284 "2021-11-16T09:06:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mihai\_Stuparu](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@Mihai\_Stuparu](https://discuss.elastic.co/u/Mihai_Stuparu)
#### Post date: [November 16, 2021, 9:06am UTC](https://discuss.elastic.co/t/call-recursively-an-api/289284/1 "2021-11-16T09:06:31Z")

</div>

Hello,  
Using below basic http\_poller request I will obtain a .json file that contains an attribute called "id".  
For each "id" I need to call other APIs, having the "id" value in the url: https://..../id.  
How can I achieve that in logstash ?

```auto
input {

    http_poller {

        urls => {

            snow => {  

                method => get

                user => "..."

                password => "..."

                url => "..."

                headers => {

                    Accept => "application/json"

                }

            }

        }

    request_timeout => 60

    schedule => { cron => "*/2 * * * * UTC"}

    codec => "json"

    }

}

```

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [November 16, 2021, 5:55pm UTC](https://discuss.elastic.co/t/call-recursively-an-api/289284/2 "2021-11-16T17:55:01Z")

</div>

You can use an http filter with a [sprintf](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#sprintf) reference to add the [id] value to the data sent to the API.

---

<div class="post-metadata">

### Author: ![Mihai\_Stuparu](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@Mihai\_Stuparu](https://discuss.elastic.co/u/Mihai_Stuparu)
#### Post date: [November 17, 2021, 7:47am UTC](https://discuss.elastic.co/t/call-recursively-an-api/289284/3 "2021-11-17T07:47:30Z")

</div>

Thanks for the advise, Badger, having a short look seems it is exactly what I needed.  
I'll try to do it sometime this week and give more details.

---

<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: [December 15, 2021, 7:47am UTC](https://discuss.elastic.co/t/call-recursively-an-api/289284/4 "2021-12-15T07:47:47Z")

</div>

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