# Feed Elasticsearch directly from a web service URL?

**URL:** <https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424>\
**Category:** Elasticsearch\
**Created:** [June 26, 2015, 1:34pm UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424 "2015-06-26T13:34:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marius\_Mathisen](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Marius\_Mathisen](https://discuss.elastic.co/u/Marius_Mathisen)\
**Post date:** [June 26, 2015, 1:34pm UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/1 "2015-06-26T13:34:51Z")

</div>

Hello,

Can I somehow feed Elasticsearch with the json file my web service produce? Like : nameofserver/api/thejsonfile ?

Or do I have to download it and feed it manually?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 26, 2015, 11:18pm UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/2 "2015-06-26T23:18:58Z")

</div>

You cannot do it directly, no.

Something like Logstash will do it, of you can do a manual curl download and then upload to ES.

---

<div class="post-metadata">

**Author:** ![Marius\_Mathisen](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Marius\_Mathisen](https://discuss.elastic.co/u/Marius_Mathisen)\
**Post date:** [June 27, 2015, 6:49am UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/3 "2015-06-27T06:49:50Z")

</div>

OK. Thank you. 🙂 Will have to look into Logstash then.

---

<div class="post-metadata">

**Author:** ![Marius\_Mathisen](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Marius\_Mathisen](https://discuss.elastic.co/u/Marius_Mathisen)\
**Post date:** [June 27, 2015, 8:05am UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/4 "2015-06-27T08:05:44Z")

</div>

Are there any spesific formatting I need to use on the JSON file? When I download the JSON file locally and try to feed it to ES I seem to do something wrong.

If I use : curl XPOST localhost:9200/server/server/\_bulk?pretty --databinary @Server.json I get the no request added error.

If I use: curl XPOST localhost:9200/server/server?pretty --databinary @Server.json it indexes it only as one object.

Here is a sample of my Server.json file, some info is changed for security reasons:

{  
"machineID":1,  
"isVirtualMachine":true,  
"name":"Server1",  
"lastActivity":"2015-06-27T06:47:03",  
"domain":"NO",  
"deviceOS":"Microsoft Windows Server 2012 Standard",  
"lastBoot":"2015-06-11T03:11:31",  
"patchePlan":"Auto",  
"owner":1  
},  
{  
"machineID":2,  
"isVirtualMachine":true,  
"name":"Server2",  
"lastActivity":"2015-06-27T06:50:57",  
"domain":"NO",  
"deviceOS":"Microsoft Windows Server 2008 R2 Standard",  
"lastBoot":"2015-06-10T22:14:27",  
"patchePlan":"Auto",  
"owner":1  
},  
{  
"machineID":3,  
"isVirtualMachine":false,  
"name":"Server3",  
"lastActivity":"2015-06-27T06:47:25",  
"domain":"NO",  
"deviceOS":"Microsoft Windows Server 2012 R2 Standard",  
"lastBoot":"2015-06-11T04:11:37",  
"patchePlan":"Auto",  
"owner":1  
},  
{  
"machineID":4,  
"isVirtualMachine":true,  
"name":"Server4",  
"lastActivity":"2015-06-27T07:01:51",  
"domain":"NO",  
"deviceOS":"Microsoft Windows Server 2012 R2 Standard",  
"lastBoot":"2015-06-11T03:12:31",  
"patchePlan":"Auto",  
"owner":1  
},  
{  
"machineID":5,  
"isVirtualMachine":true,  
"name":"Server5",  
"lastActivity":"2015-06-27T06:55:27",  
"domain":"NO",  
"deviceOS":"Microsoft Windows Server 2008 R2 Enterprise",  
"lastBoot":"2015-06-11T17:43:17",  
"patchePlan":"Manual",  
"owner":1  
}

Is this format in JSON wrong? If so, how should it be?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 27, 2015, 8:21am UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/5 "2015-06-27T08:21:12Z")

</div>

If you use bulk you need to respect bulk format:  
Header  
Payload  
Header  
Payload  
..,

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)

---

<div class="post-metadata">

**Author:** ![Marius\_Mathisen](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Marius\_Mathisen](https://discuss.elastic.co/u/Marius_Mathisen)\
**Post date:** [June 27, 2015, 10:39am UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/6 "2015-06-27T10:39:01Z")

</div>

So basically the same format as in the accounts.json file in the guide?

{"index":{"\_id":"1"}}  
{"account\_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes [Lane","employer":"Pyrami","email":"amberduke@pyrami.com](mailto:Lane%22,%22employer%22:%22Pyrami%22,%22email%22:%22amberduke@pyrami.com)","city":"Brogan","state":"IL"}

Is this something we have to do manually, or do we have a script/formatter to automatic format json-files correctly with Header, Payload, Header, Payload?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 27, 2015, 10:54am UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/7 "2015-06-27T10:54:37Z")

</div>

Well it depends on which client you are using.  
In Java, you have some classes for example to simplify all that.

As @warkolm suggested, you could look at logstash. May be this plugin might help you: [https://github.com/logstash-plugins/logstash-input-http-poller](https://github.com/logstash-plugins/logstash-input-http-poller)

---

<div class="post-metadata">

**Author:** ![Marius\_Mathisen](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Marius\_Mathisen](https://discuss.elastic.co/u/Marius_Mathisen)\
**Post date:** [June 27, 2015, 11:02am UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/8 "2015-06-27T11:02:08Z")

</div>

Yeah, seems like that´s the way to go. 😄

Thank you. 🙂

---

<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:** [July 6, 2017, 12:04am UTC](https://discuss.elastic.co/t/feed-elasticsearch-directly-from-a-web-service-url/24424/9 "2017-07-06T00:04:59Z")

</div>


