def fetch_state_data(state, lat, lon, parameters, start_date, end_date, community="AG"):
    """
    Fetch climate data for a specific state from the NASA Power API.

    Args:
        state (str): Name of the state.
        lat (float): Latitude of the state's centroid.
        lon (float): Longitude of the state's centroid.
        parameters (str): Climate parameters to fetch.
        start_date (str): Start date in YYYYMM format.
        end_date (str): End date in YYYYMM format.
        community (str): Community parameter for the API. Defaults to "AG" (Agroclimatology).

    Returns:
        DataFrame: Climate data for the state or empty DataFrame if failed.
    """
    import requests
    import pandas as pd
    from io import StringIO
    from datetime import datetime, date

    # Validate dates
    current_date = date.today()
    try:
        # Convert YYYYMM to datetime for comparison
        start_dt = datetime.strptime(start_date, "%Y%m").date()
        end_dt = datetime.strptime(end_date, "%Y%m").date()
        
        # Adjust end date if it's in the future
        if end_dt > current_date:
            end_dt = current_date
            end_date = current_date.strftime("%Y%m")
            print(f"Adjusted end date to current date: {end_date}")
        
        # Convert to YYYYMMDD format for API
        start_date = start_dt.strftime("%Y%m01")
        end_date = end_dt.strftime("%Y%m01")
    except ValueError as e:
        print(f"Date format error: {e}")
        return pd.DataFrame()

    base_url = "https://power.larc.nasa.gov/api/temporal/monthly/point"
    params = {
        "parameters": parameters,
        "longitude": f"{lon:.4f}",
        "latitude": f"{lat:.4f}",
        "start": start_date,
        "end": end_date,
        "format": "CSV",
        "community": community  # Always include community parameter
    }

    print(f"Fetching data for {state} (Lat: {lat}, Lon: {lon})")
    print(f"Request parameters: {params}")
    
    try:
        response = requests.get(base_url, params=params, timeout=30)
        response.raise_for_status()
        
        if response.status_code == 204:
            print(f"No data available for {state}")
            return pd.DataFrame()

        csv_content = response.text
        csv_lines = csv_content.splitlines()

        # Dynamically find the header line containing 'YYYYMM'
        header_line = None
        for idx, line in enumerate(csv_lines):
            if 'YYYYMM' in line:
                header_line = idx
                break

        if header_line is not None and len(csv_lines) > header_line + 1:
            csv_data = '\n'.join(csv_lines[header_line:])
            state_data = pd.read_csv(StringIO(csv_data))
            
            # Check if necessary columns are present
            expected_columns = ['YYYYMM'] + parameters.split(',')
            missing_columns = [col for col in expected_columns if col not in state_data.columns]
            
            if not missing_columns:
                state_data['State'] = state
                return state_data
            else:
                print(f"Missing columns for {state}: {missing_columns}")
                return pd.DataFrame()
        else:
            print(f"No data found for {state}.")
            return pd.DataFrame()
            
    except requests.exceptions.HTTPError as http_err:
        print(f"HTTP error occurred for {state}: {http_err}")
        if response.status_code == 422:
            print(f"API Request parameters: {params}")
            print("Possible issues:")
            print("1. Date range might be invalid")
            print("2. Coordinates might be outside valid range")
            print("3. Parameters might be invalid for the selected community")
        return pd.DataFrame()
    except requests.exceptions.Timeout:
        print(f"Request timed out for {state}")
        return pd.DataFrame()
    except Exception as err:
        print(f"Other error occurred for {state}: {err}")
        return pd.DataFrame()

This function keeps getting 422 error. 

The correct scheme is like this:

    api_url = "https://power.larc.nasa.gov/api/temporal/daily/point"
    params = {
        "parameters": "ALLSKY_SFC_SW_DWN",
        "community": "SB",
        "longitude": longitude,
        "latitude": latitude,
        "start": "20200101",
        "end": "20201231",
        "format": "JSON"
    }

I just want you to modify the function so that the function which is getting error 422 right now gets the data it wants (temperature, precipitation etc.)