Rest resource template with sensor value in url - unsplash

I’m trying to get a random unsplash photo using a sensor value that sets a theme. However, it seems resource doesn’t accept sensors. Is there a solution for this problem?

Thank you for helping me.

rest:
  - resource: https://api.unsplash.com/photos/random?query=wallpaper,{{ states('sensor.background_theme') | urlencode }}&orientation=landscape&client_id=apikey
    scan_interval: 1800
    method: GET
    headers:
      Content-Type: application/json
    sensor:
      name: "Unsplash Background"
      unique_id: unsplash_background
      json_attributes:
        - urls
      value_template: >
        {% if value_json and and value_json.urls and value_json.urls.full %}
          {{ value_json.urls.full }}
        {% endif %}

Use resource_template rather than resource

Thanks! I’ve tried using resource_template, but get error message:

Template variable warning: 'dict object' has no attribute 'urls' when rendering '{% if value_json and value_json.urls and value_json.urls.full %} {{ value_json.urls.full }} {% endif %}'

rest:
  - resource_template: >-
      https://api.unsplash.com/photos/random?query=wallpaper,{{ states('sensor.background_theme') | urlencode }}&orientation=landscape&client_id=apikey
    scan_interval: 1800
    method: GET
    headers:
      Content-Type: application/json
    sensor:
      name: "Unsplash Background"
      unique_id: unsplash_background
      json_attributes:
        - urls
      value_template: >-
        {% if value_json and value_json.urls and value_json.urls.full %}
          {{ value_json.urls.full }}
        {% endif %}