You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by Florian Micklich <mi...@apache.org> on 2022/09/13 11:03:48 UTC

Create Adapter from HTTP Source

Hi all,

I want to create an adapter from following source [1]

Therefore I created an Adapter => Connect -> New Adapter -> HTTP
Stream.
As selected format I used JSON and Format Array but the result differs
from the raw json [2]
Is just the source json messed up in some way  or do I miss something
in the adapter part?


Greeting 
Florian

[1] 
https://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/BONN.json?includeTimeseries=true&includeCurrentMeasurement=true
[2]

{
  "uuid": "593647aa-9fea-43ec-a7d6-6476a76ae868",
  "number": "2710080",
  "shortname": "BONN",
  "longname": "BONN",
  "km": 654.8,
  "agency": "STANDORT DUISBURG",
  "longitude": 7.108045442593695,
  "latitude": 50.73639800887676,
  "water": {
    "shortname": "RHEIN",
    "longname": "RHEIN"
  },
  "timeseries": [
    {
      "shortname": "W",
      "longname": "WASSERSTAND ROHDATEN",
      "unit": "cm",
      "equidistance": 15,
      "currentMeasurement": {
        "timestamp": "2022-09-13T12:30:00+02:00",
        "value": 161.0,
        "trend": -1,
        "stateMnwMhw": "normal",
        "stateNswHsw": "unknown"
      },
      "gaugeZero": {
        "unit": "m. ü. NHN",
        "value": 42.713,
        "validFrom": "2019-11-01"
      }
    },
    {
      "shortname": "Q",
      "longname": "ABFLUSS_ROHDATEN",
      "unit": "m³/s",
      "equidistance": 15,
      "currentMeasurement": {
        "timestamp": "2022-09-13T12:15:00+02:00",
        "value": 997.0,
        "trend": 0
      }
    }
  ]
}



AW: Create Adapter from HTTP Source

Posted by Philipp Zehnder <ph...@bytefabrik.ai>.
Hi Florian,

which kind of data do you want to read as events from the json?
The whole event or the events in the time series array?
If you want to read the whole event, then you have to select (Json+SingleObject), when you only want to read the timeseries array then you must select (Json+Array Field) with the Key ‘timeseries’.

However, I guess there could also be some problems with this data.
It seems that the events in the ‘timeseries’ array do not have a fixed schema. They represent different sensor types.
Usually, StreamPipes expects one adapter to have a fixed event schema in which all properties are set for each event.

I hope this information helpful, if you have further questions please let me know.

Kind regards,
Philipp


Von: Florian Micklich <mi...@apache.org>
Datum: Dienstag, 13. September 2022 um 13:03
An: dev <de...@streampipes.apache.org>
Betreff: Create Adapter from HTTP Source
Hi all,

I want to create an adapter from following source [1]

Therefore I created an Adapter => Connect -> New Adapter -> HTTP
Stream.
As selected format I used JSON and Format Array but the result differs
from the raw json [2]
Is just the source json messed up in some way  or do I miss something
in the adapter part?


Greeting
Florian

[1]
https://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/BONN.json?includeTimeseries=true&includeCurrentMeasurement=true
[2]

{
  "uuid": "593647aa-9fea-43ec-a7d6-6476a76ae868",
  "number": "2710080",
  "shortname": "BONN",
  "longname": "BONN",
  "km": 654.8,
  "agency": "STANDORT DUISBURG",
  "longitude": 7.108045442593695,
  "latitude": 50.73639800887676,
  "water": {
    "shortname": "RHEIN",
    "longname": "RHEIN"
  },
  "timeseries": [
    {
      "shortname": "W",
      "longname": "WASSERSTAND ROHDATEN",
      "unit": "cm",
      "equidistance": 15,
      "currentMeasurement": {
        "timestamp": "2022-09-13T12:30:00+02:00",
        "value": 161.0,
        "trend": -1,
        "stateMnwMhw": "normal",
        "stateNswHsw": "unknown"
      },
      "gaugeZero": {
        "unit": "m. ü. NHN",
        "value": 42.713,
        "validFrom": "2019-11-01"
      }
    },
    {
      "shortname": "Q",
      "longname": "ABFLUSS_ROHDATEN",
      "unit": "m³/s",
      "equidistance": 15,
      "currentMeasurement": {
        "timestamp": "2022-09-13T12:15:00+02:00",
        "value": 997.0,
        "trend": 0
      }
    }
  ]
}