Creating a URL with a template

Hi,
I am trying to get tide info from NOAA to display on my dashboard using the “rest” sensor platform. I have to build a long URL string that contains today and tomorrow’s date. I figured out how to get the dates in the correct format:

{{ now().timestamp() | timestamp_custom("%Y%m%d") }}
{{ (now() + timedelta( days = 1)).timestamp() | timestamp_custom("%Y%m%d") }}

However, when I try to embed it in the string, the sensor no longer works. See below. tideValue1 doesn’t work but tideValue2 does.

  - platform: rest
    name: tideValue1
    json_attributes_path: "$.predictions.[0]."
    json_attributes:
      - t
      - v
      - type
    resource: >
        https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?product=predictions&application=NOS.COOPS.TAC.WL&begin_date=
        {{ now().timestamp() | timestamp_custom('%Y%m%d' ) }}
        &end_date=
        {{ (now() + timedelta( days = 1)).timestamp() | timestamp_custom('%Y%m%d') }}
        &datum=MLLW&station=9410840&time_zone=lst_ldt&units=english&interval=hilo&format=json
    value_template: "{{ value_json[0].t }}"
  - platform: rest
    name: tideValue2
    json_attributes_path: "$.predictions.[0]."
    json_attributes:
      - t
      - v
      - type
    resource: https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?product=predictions&application=NOS.COOPS.TAC.WL&begin_date=20220104&end_date=20220104&datum=MLLW&station=9410840&time_zone=lst_ldt&units=english&interval=hilo&format=json
    value_template: "{{ value_json[1].t }}"


try replacing

resource:

with

resource_template: