Rest API Call - get all element from a dynamic array

Hi,

i d like to get all “warning” inside “warnings” one sensor per “warning” - the problem I have that this could be 1…n.

At the moment I address them static which can result in an error if there are no warnings at all.

How can I change the warnings[0] to a more dynamic request?

thanks

eg:

rest:

API Call:

{
  "type": "Feature",

  "properties": {
    "location": {
      "type": "Municipal",
      "properties": {
        "gemeindenr": 30740,
        "name": "Schwechat",
        "urlname": "schwechat"
      }
    },
    "warnings": [
      {
        "type": "Warning",
        "properties": {
          "warnid": 4149,
          "chgid": 6,
          "verlaufid": 2,
          "warntypid": 1,
          "begin": "27.03.2023 08:00",
          "end": "27.03.2023 18:00",
          "create": "2023-03-27 06:00:00+00",
          "updategrund": "",
          "warnstufeid": 1,
          "rawinfo": {
            "wtype": 1,
            "wlevel": 1,
            "start": "1679896800",
            "end": "1679932800"
          }
        }
      },
      {
        "type": "Warning",
        "properties": {
          "warnid": 4150,
          "chgid": 2,
          "verlaufid": 1,
          "warntypid": 1,
          "begin": "28.03.2023 08:00",
          "end": "28.03.2023 18:00",
          "create": "2023-03-27 08:00:00+00",
          "updategrund": "",
          "warnstufeid": 1,
          "rawinfo": {
            "wtype": 1,
            "wlevel": 1,
            "start": "1679983200",
            "end": "1680019200"
          }
        }
      }
    ]
  }
}
json_attributes_path: "$.properties"
json_attributes:
  - warnings

Please format your code properly for the forum.

That gets them all into the attributes. If you really want one per sensor, see my answer here:

1 Like