How to sent application/xml request body in a http_poller endpoint

I am having difficulties setting XML in request body to a http_poller endpoint. When I set the request body in http_poller endpoint is showing error

My conf file

    input {
  http_poller {
	schedule => { cron => "* * * * * UTC"}
    # List of urls to hit
    # URLs can either have a simple format for a get request
    # Or use more complex HTTP features
    urls =>  {
      some_other_service => {
        method => "post"
        url => "I have removed the url due to securuty purposes"            
        headers => {
          Accept => "application/xml"
        }   
	body => {
	'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ReqListLocation><User><Login>username111</Login><Password>password!</Password></User><Location><Disabled>1</Disabled><Type>P</Type></Location></ReqListLocation>'
        }   
      }
    }
    # Maximum amount of time to wait for a request to complete
    request_timeout => 30
    # How far apart requests should be
    #interval => 60
    # Decode the results as xml
    codec => "xml"
    # Store metadata about the request in this key
    metadata_target => "http_poller_metadata"
  }
    }
    output {
      stdout {
        codec => rubydebug
      }
    }

Error stack trace

[ERROR] 2018-08-10 08:10:36.703 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, => at line 16, column 9 (byte 713) after input {\n http_poller {\n\tschedule => { cron => \"* * * * * UTC\"}\n # List of urls to hit\n # URLs can either have a simple format for a get request\n # Or use more complex HTTP features\n urls => {\n some_other_service => {\n method => \"post\"\n url => \"url to post\" \n headers => {\n Accept => \"application/xml\"\n } \n\tbody => {\n '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ReqListLocation><User><Login>username111</Login><Password>password</Password></User><Location><Disabled>1</Disabled><Type>P</Type></Location></ReqListLocation>'\n ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:42:incompile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:50:in compile_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:12:inblock in compile_sources'", "org/jruby/RubyArray.java:2486:in map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:incompile_sources'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:49:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:167:ininitialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:40:in execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:305:inblock in converge_state'"]}`

body => "..."

not

body => { "..." }

Though I can't see any documentation of the body option.

Thanks @magnusbaeck Its working now!

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