# Problem with POST xml request with http\_poller plugin

**URL:** <https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [May 26, 2020, 1:15pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343 "2020-05-26T13:15:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ranjan\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjan_kumar/32/49699_2.png) [@Ranjan\_Kumar](https://discuss.elastic.co/u/Ranjan_Kumar)\
**Post date:** [May 26, 2020, 1:15pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/1 "2020-05-26T13:15:25Z")

</div>

Hi ,

I am using logstash to send post data to elastic node but i am getting this.  
Please help me regarding this.

## logstash\_post.conf

input {  
http\_poller {  
urls =\> {  
method =\> post  
schedule =\> {cron =\> "\* \* \* \* \* UTC"}  
url =\> " here i keep my api url with token"  
headers =\> {  
Accept =\> "application/xml"  
}  
body =\> "\<?xml version="1.0" encoding="UTF-8"?\>.........  
......................................."  
}  
request\_timeout =\> 60  
codec =\> "json"  
metadata\_target =\> "http\_poller\_metadata"  
}  
}

filter {}  
output {  
elasticsearch {  
action =\> "index"  
hosts =\> ["elasticsearch:9200"]  
user =\> "username"  
password =\> "password"  
index =\> "logstash-sdp-req-post-%{+yyyy.MM.dd}"  
}  
}

## error in terminal:

logstash\_1 | [2020-05-26T12:45:15,141][ERROR][logstash.agent] Failed to execute action {:action=\>LogStash::PipelineAction::Create/pipeline\_id:main, :exception=\>"LogStash::ConfigurationError", :message=\>"Expected one of [\t\r\n], "#", "{", "}" at line 10, column 31 (byte 321) after input {\n http\_poller {\n urls =\> {\n method =\> post\n schedule =\> { cron =\> "\* \* \* \* \* UTC"}\n url =\> "my rest api url with token "\n headers =\> {\n Accept =\> "application/xml"\n }\n body =\> "\<?xml version="", :backtrace=\>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:41:in `compile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:49:in `compile\_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:in `block in compile_sources'", "org/jruby/RubyArray.java:2580:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:10:in `compile_sources'", "org/logstash/execution/AbstractPipelineExt.java:161:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:47:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:27:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline\_action/create.rb:36:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:326:in `block in converge\_state'"]}

---

<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:** [May 26, 2020, 3:00pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/2 "2020-05-26T15:00:29Z")

</div>

> [@Ranjan\_Kumar](#):
>
> body =\> "\<?xml version="1.0" encoding="UTF-8"?\>.........  
> ......................................."

You have double quotes inside your double quoted string. Either escape them or use single quotes around the string

```
body => '<?xml version="1.0" encoding="UTF-8"?>.........
.......................................'

```

---

<div class="post-metadata">

**Author:** ![Ranjan\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjan_kumar/32/49699_2.png) [@Ranjan\_Kumar](https://discuss.elastic.co/u/Ranjan_Kumar)\
**Post date:** [May 27, 2020, 6:30am UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/3 "2020-05-27T06:30:15Z")

</div>

Thanks , Solved

---

<div class="post-metadata">

**Author:** ![Ranjan\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjan_kumar/32/49699_2.png) [@Ranjan\_Kumar](https://discuss.elastic.co/u/Ranjan_Kumar)\
**Post date:** [May 28, 2020, 8:48pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/4 "2020-05-28T20:48:34Z")

</div>

Hi Badger,

I am not getting any response data in elastic search index. But when I hit url in postman then I got response data.

Is any way to get response data and index to elastic search through http polar plugin.

---

<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:** [May 28, 2020, 10:08pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/5 "2020-05-28T22:08:19Z")

</div>

> [@Ranjan\_Kumar](#):
>
> Is any way to get response data and index to Elasticsearch through http polar plugin.

There is certainly a way. The http\_poller exists in order to let people do that.

---

<div class="post-metadata">

**Author:** ![Ranjan\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjan_kumar/32/49699_2.png) [@Ranjan\_Kumar](https://discuss.elastic.co/u/Ranjan_Kumar)\
**Post date:** [May 29, 2020, 7:22am UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/6 "2020-05-29T07:22:45Z")

</div>

Hi Badger,

I wrote below conf file.

## abc.conf:

input {  
http\_poller {  
urls =\> {  
q1 =\> {  
method =\> post  
url =\> "url with token"  
headers =\> {  
Accept =\> "application/xml"  
}  
body =\> '\<?xml version="1.0" encoding="UTF-8"?\>\<API version="1.0" locale="en  
......................'  
}  
}  
type =\> "allassets"  
request\_timeout =\> 60  
codec =\> "json"  
schedule =\> {cron =\> "\* \* \* \* \* UTC"}  
metadata\_target =\> "http\_poller\_metadata"  
}  
}

filter {}

output {  
if [type] == "allassets"{  
elasticsearch {  
action =\> "index"  
hosts =\> ["elasticsearch:9200"]  
user =\> "user"  
password =\> "password"  
index =\> "sdp-allassets-%{+yyyy.MM.dd}"  
}  
}  
}  
i did't get any response data in elastic search index.But when i keep same body parameter in postman then i get data with same api with token.

Please help me, if any correction needed.  
Thanks

---

<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:** [May 29, 2020, 7:19pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/7 "2020-05-29T19:19:54Z")

</div>

I would suggest looking at the logs of whatever service you are calling to see if that indicates why it is not providing a response.

---

<div class="post-metadata">

**Author:** ![Ranjan\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjan_kumar/32/49699_2.png) [@Ranjan\_Kumar](https://discuss.elastic.co/u/Ranjan_Kumar)\
**Post date:** [May 29, 2020, 8:10pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/9 "2020-05-29T20:10:41Z")

</div>

While debugging i got this.Can you please tell me what i need to change in my conf file.

logstash\_1 | [2020-05-29T19:22:00,908][WARN][logstash.outputs.elasticsearch][main] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"sdp-allassets-2020.05.29", :routing=\>nil, :\_type=\>"\_doc"}, #LogStash::Event:0x13efdddd], :response=\>{"index"=\>{"\_index"=\>"sdp-allassets-2020.05.29", "\_type"=\>"\_doc", "\_id"=\>"ldPiYXIBS5TN\_1CHT4Yi", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"mapper [API.response.operation.Details.field-values.record.value] of different type, current\_type [long], merged\_type [text]"}}}}

---

<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:** [May 29, 2020, 8:27pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/10 "2020-05-29T20:27:56Z")

</div>

In the index you are writing to the field API.response.operation.Details.field-values.record.value has type long, possibly because in the first document that was indexed it was indeed a number. However, in that document the field is text. The answer is to create an index template that sets the type of that field before any documents are added.

If you have to add every field to the template that could be a considerable amount of work, but for now, just add the ones that cause a conflict, delete the index and index the documents a second time.

---

<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:** [June 26, 2020, 8:28pm UTC](https://discuss.elastic.co/t/problem-with-post-xml-request-with-http-poller-plugin/234343/11 "2020-06-26T20:28:00Z")

</div>

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