POST form data with Logstash http_poller input plug-in


(Michael Stone) #1

Hi,

I'm trying to use the http_poller input plug-in to recreate the curl statement below.

curl --user xps_client: --basic --data "username=admin&password=admin&scope=XPS_API_ALL&grant_type=password" http://xps.invigorinsights.com/oauth/token

My input configuration is as follows:

input {
  http_poller {
    urls => {
      test => {
        # Supports all options supported by ruby's Manticore HTTP client
        method => post
        url => "http://xps.invigorinsights.com/oauth/token"
        user => "xps_client"
        password => ""
        headers => {
            content-type => "application/x-www-form-urlencoded"
        }
        body => "username=admin&password=password&scope=XPS_API_ALL&grant_type=password"
      }
    }
    request_timeout => 60
    # Supports "cron", "every", "at" and "in" schedules by rufus scheduler
    schedule => { every => "1d"}
    codec => "json"
    # A hash of request metadata info (timing, response headers, etc.) will be sent here
    metadata_target => "http_poller_metadata"
  }
}

I'm getting an error back from the request which suggests the body is not correctly formatted.

Can anyone see what I'm doing wrong?

Thanks,

Michael


(Michael Stone) #2

Ended up finding a work around as the user and password parameters don't seem to work for Basic authorization.

I used TCPDUMP to see what Logstash is actually calling and there is no Authorization header being passed.

To get this to work, I copied the Authorization header value (Basic ) value from running TCPDUMP with the original curl command.

Got rid of the user and password parameters in the input filter config and it now works.


(system) #3

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