How to send url with jinja in RESTFUL api

How to sent jinja in URL ?

sample url
https://api.data.gov.sg/v1/environment/2-hour-weather-forecast?date_time=2019-01-17T18:13:00

sensor:
    - platform: rest
      resource: "https://api.data.gov.sg/v1/environment/2-hour-weather-forecast?date_time={{ now().strftime('%Y-%m-%dT%H:%M:00') }}"
      method: GET
      value_template: '{{value_json.item.forecasts.0.forecast}}'

DEBUG
2019-02-17 19:24:22 DEBUG (SyncWorker_0) [homeassistant.components.sensor.rest] Updating from https://api.data.gov.sg/v1/environment/2-hour-weather-forecast?date_time=%7B%7B%20now().strftime(%22%25Y-%25m-%25dT%25H:%25M:00%22)%20%7D%7D

REST sensor doesn’t support templating in the URL unfortunately - however you can achieve this with a command_line sensor instead:

- platform: command_line
    name: forecast
    value_template: '{{value_json.item.forecasts.0.forecast}}'
    command: >-
      curl '"'https://api.data.gov.sg/v1/environment/2-hour-weather-forecast?date_time={{ now().strftime("%Y-%m-%dT%H:%M:00") }}"'"

Got this error instead

Error loading /config/configuration.yaml: mapping values are not allowed here

Can you post your configuration.yaml?

some indentation issue

    - platform: command_line
      name: forecast
      value_template: '{{value_json.item.forecasts.0.forecast}}'
      command: >-
        curl '"'https://api.data.gov.sg/v1/environment/2-hour-weather-forecast?date_time={{ now().strftime("%Y-%m-%dT%H:%M:00") }}"'"
    ```

It looks correct now but I still trying to get the data from json

Sorry about the indentation error! What you have there is correct.

The problem is your value_template - it doesn’t match up at all with the returned JSON from the request you’re sending. The request just returns a load of places and coordinates:

{

"area_metadata":[

{

"name": "Ang Mo Kio",

"label_location":{

"latitude": 1.375,

"longitude": 103.839

}

},

{

"name": "Bedok",

"label_location":{

"latitude": 1.321,

"longitude": 103.924

}

},

{

"name": "Bishan",

"label_location":{

"latitude": 1.350772,

"longitude": 103.839

}

You need to go back and double check your GET request

Got it running

- platform: command_line
  name: sgneaweb
  command: >-
    curl "'"https://api.data.gov.sg/v1/environment/2-hour-weather-forecast?date_time={{ now().strftime("%Y-%m-%dT%H:%M:00") }}"'"
  value_template: >-
    {%- for entry in value_json['items'][0].forecasts -%}
    {%- if entry.area == 'Boon Lay' -%}{{ entry.forecast }}{%- endif -%}
    {%- endfor -%}