Single REST call for multiple entites

I want to make a REST call to retrieve to pieces of data, moonrise and moonset. I can make it work using two separate calls, but from the docs, I should be able get the two sensors populated in a single call.

Here are the the calls I use:

- platform: rest
  resource: !secret visual_crossing_moon_data
  name: "Moon Rise"
  scan_interval: 43200
  json_attributes_path: "$.days[0]"
  json_attributes:
      - moonrise
  value_template: "{{ value_json['days[0]']['moonrise']}}"  
  
  
- platform: rest
  resource: !secret visual_crossing_moon_data
  name: "Moon Set"
  scan_interval: 43200
  json_attributes_path: "$.days[0]"
  json_attributes:
      - moonset
  value_template: "{{ value_json['days[0]']['moonset']}}"  

Here’s what I tried using the example I found the docs:

rest:
  - resource: !secret visual_crossing_moon_data
    sensor:
      - name: "Moon Rise
        value_template: "{{ value_json.days[0]['moonrise'] }}"

      - name: "Moon Set"
        value_template: "{{ value_json.days[0]['moonset'] }}"

With code in my configuration.yaml, I get the error, “resource is an invalid key”

Here’s the doc reference:

RESTFul Sensor docs

Did you put that in your sensors.yaml file?

It is not a sensor. It is the restful integration (that can create sensors). It goes in your configuration.yaml file.

Or you can use an include in your configuration.yaml file

rest: !include rest_sensors.yaml

rest_sensors.yaml

- resource: !secret visual_crossing_moon_data
  sensor:
    - name: "Moon Rise
      value_template: "{{ value_json.days[0]['moonrise'] }}"

    - name: "Moon Set"
      value_template: "{{ value_json.days[0]['moonset'] }}"

Thanks, I did put what you posted in my confutation.yaml, but there was a syntax error I didn’t catch. I works fine now.
Thanks again.