# Http\_poller - URL from another field

**URL:** https://discuss.elastic.co/t/http-poller-url-from-another-field/277722
**Category:** Logstash
**Created:** [July 4, 2021, 6:46am UTC](https://discuss.elastic.co/t/http-poller-url-from-another-field/277722 "2021-07-04T06:46:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RoteEdition](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roteedition/32/91103_2.png) [@RoteEdition](https://discuss.elastic.co/u/RoteEdition)
#### Post date: [July 4, 2021, 6:46am UTC](https://discuss.elastic.co/t/http-poller-url-from-another-field/277722/1 "2021-07-04T06:46:22Z")

</div>

Hi there,  
I am trying to get some data (regarding incoming calls) from an API. I am using http\_poller and everything seems to work.

The Problem: The URL has a date parameter in it. I dont want to update the URL everyday, so I thought I would create a field for the current date and then just combine the URL with the date field. Unfortunately I can't get the reference to the according field working.

Here ist the .conf

```auto
input {
  http_poller {
    add_field => { "time" => "%{+YYYY-MM-dd}"}
    add_field => { "apiurl" => "https://XX.com/call_detail_records?per_page=100&date=%{time}"}
    urls => {
      call_url => {
        # Supports all options supported by ruby's Manticore HTTP client
        method => get
        url => "%{apiurl}"
        headers => {
          Authorization => "XXX"
        }
     }
    }
    # Supports "cron", "every", "at" and "in" schedules by rufus scheduler
    schedule => { "every" => "5m" }
    codec => "json"
  }
}

```

And that's the resulting error:

```auto
[main] Pipeline error {:pipeline_id=>"main", :exception=>#<LogStash::ConfigurationError: Invalid URL %{apiurl}>, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-http_poller-5.0.2/lib/logstash/inputs/http_poller.rb:103:in `validate_request!'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-http_poller-5.0.2/lib/logstash/inputs/http_poller.rb:95:in `normalize_request'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-http_poller-5.0.2/lib/logstash/inputs/http_poller.rb:55:in `block in setup_requests!'", "org/jruby/RubyHash.java:1415:in `each'", "org/jruby/RubyEnumerable.java:886:in `map'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-http_poller-5.0.2/lib/logstash/inputs/http_poller.rb:55:in `setup_requests!'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-http_poller-5.0.2/lib/logstash/inputs/http_poller.rb:45:in `register'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:228:in `block in register_plugins'", "org/jruby/RubyArray.java:1809:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:227:in `register_plugins'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:386:in `start_inputs'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:311:in `start_workers'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:185:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:137:in `block in start'"], "pipeline.sources"=>["/usr/share/logstash/pipeline/back/logstash-calls.conf"], :thread=>"#<Thread:0x4ff385dd@/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:54 run>"}

```

As always thank you for helping me out.

Kind Regards  
Marvin

---

<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: [July 4, 2021, 1:26pm UTC](https://discuss.elastic.co/t/http-poller-url-from-another-field/277722/2 "2021-07-04T13:26:03Z")

</div>

> [@RoteEdition](#):
>
> Unfortunately I can't get the reference to the according field working.

This is not going to work. The add\_field is part of event decoration, and that is done after the http call has successfully completed. Also, there is no event from which you can reference fields when the HTTP request is being constructed.

If you need to do this you could use any input that supports a schedule option to create empty events, and then use mutate to do the add\_field, followed by an http filter to do the API call.

---

<div class="post-metadata">

### Author: ![RoteEdition](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roteedition/32/91103_2.png) [@RoteEdition](https://discuss.elastic.co/u/RoteEdition)
#### Post date: [July 5, 2021, 6:33am UTC](https://discuss.elastic.co/t/http-poller-url-from-another-field/277722/3 "2021-07-05T06:33:48Z")

</div>

I see. This sounds logical. I probably need to open another thread, bc this introduces a new set of weird problems. Still thank you very much for pointing this out.  
Have a nice day!

---

<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, 6:34am UTC](https://discuss.elastic.co/t/http-poller-url-from-another-field/277722/4 "2021-08-02T06:34:06Z")

</div>

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