Подскажите как правильно здесь написать реалтзацию и почему intellij выделяет красным httpHeaders

Будет супер если сможет кто то обьяснить И как делать реквест хэдер?

import com.example.Weather.web.ForecastService;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

@Service

public class ForecastServiceRestImpl implements ForecastService {
   private final RestTemplate restTemplate;
    private static String URL = "https://community-open-weather-map.p.rapidapi.com/weather?units=metric&mode=json&q=";

    public ForecastServiceRestImpl(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
        HttpHeaders headers = new HttpHeaders();
        headers.set("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
        headers.set("x-rapidapi-key", "cdd96ad95amsheebcca53e65aac1p136010jsn18e30e4e6350");

    }


    @Override
    public String getForecast() {

        HttpEntity<String> request = new HttpEntity<>(URL, httpHeaders);
        ResponseEntity<String> responseEntity =
                restTemplate.getForEntity(URL,  String.class);
        return responseEntity.getBody();
    }
}

Ответы (0 шт):