# Query against REST API of a third party device

**URL:** https://discuss.elastic.co/t/query-against-rest-api-of-a-third-party-device/222979
**Category:** Logstash
**Created:** [March 10, 2020, 4:37pm UTC](https://discuss.elastic.co/t/query-against-rest-api-of-a-third-party-device/222979 "2020-03-10T16:37:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rudiz](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@rudiz](https://discuss.elastic.co/u/rudiz)
#### Post date: [March 10, 2020, 4:37pm UTC](https://discuss.elastic.co/t/query-against-rest-api-of-a-third-party-device/222979/1 "2020-03-10T16:37:24Z")

</div>

I'm trying to query a storage device via RESTful API. I have to send a POST against the endpoint /auth with User and Password in the header to get a token. This token remains valid for 2hours or 30minutes if no activity. Here the example with curl:  
_[root@elasticnode1 logstash]# curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Username: superuser' -H 'X-Auth-Password: passw0rd' [https://192.168.18.140:7443/rest/auth](https://192.168.18.140:7443/rest/auth)_  
and this gives me back:  
_{"token": "7b0867758147551d57c6a3f758ae40a44820fbb9fd7a529517c43d74f683f4b0"}_

Now I need to use this Token in the header of my data request endpoints /rest/ as demonstrated in the following curl example:  
\*[root@elasticnode1 logstash]# curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token:7b0867758147551d57c6a3f758ae40a44820fbb9fd7a529517c43d74f683f4b0' [https://192.168.18.140:7443/rest/lscluster](https://192.168.18.140:7443/rest/lscluster)  
\*  
Answers me back:  
_[{ "id": "00000200604184D6", "name": "Zurich", "location": "local", "partnership": "", "bandwidth": "", "id\_alias": "000002006400C582" },  
{ "id": "0000020064804138", "name": "Luzern", "location": "remote", "partnership": "fully\_configured", "bandwidth": "62", "id\_alias": "0000020063A04004" }_  
as this is the JSON format I need to forward to ES.

I tried to use the "logstash-filter-rest" ([https://github.com/lucashenning/logstash-filter-rest](https://github.com/lucashenning/logstash-filter-rest)) and was able to build a pipeline but no data was gathered. Got some hint that the usage of http input plugin would be a better way. Sorry but I did not find any related example and I'm a new logstash user.  
Any help is welcome.

---

<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: [March 10, 2020, 5:14pm UTC](https://discuss.elastic.co/t/query-against-rest-api-of-a-third-party-device/222979/2 "2020-03-10T17:14:18Z")

</div>

You could put the first POST in an http\_poller input then use the resulting token in an http filter.

---

<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: [April 7, 2020, 5:14pm UTC](https://discuss.elastic.co/t/query-against-rest-api-of-a-third-party-device/222979/3 "2020-04-07T17:14:23Z")

</div>

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