My code is continuously throwing my catch exception and I don’t know why

Solution for My code is continuously throwing my catch exception and I don’t know why
is Given Below:

I am creating a project that uses an API access key to get stock data information. The user types in the stock symbol, and hits a button that will then load all of the stock information. However, when type in a correct stock symbol and click the button to load the information, it continuously throws my catch exception that I set up and I don’t know why. I have never used try catch before so am I doing something wrong?

Here is my method in my SettingsTab.cs that try’s to get the stock info:

async void AddStockButton_Clicked(object sender, EventArgs e)
            string symbol = symbolEntry.Text.ToLower();
            //Create a try catch block to make sure the symbol exists and isn't already added in the list
                //Create new data manager and pass in the users chosen symbol
                DataManager dataManager = new DataManager(symbol);
                StockData newStockData = await dataManager.GetStock();
            if (stockList.Contains(newStockData))
                //If stock does not exists or is a duplicate, display error alert
                //Change success label text to Unsuccessful, change color to red, & make visible
                await DisplayAlert("DUPLICATE STOCK", "This stock is already added to your favorites!", "OKAY");
                successLabel.Text = "Unsuccessful due to duplicate";
                successLabel.TextColor = Color.Red;
                successLabel.IsVisible = true;
            else if (!stockList.Contains(newStockData))
                //If stock exists and not duplicate, add that stock to a list of stockData
                //Display success alert
                //Make success label visible
                await DisplayAlert("STOCK ADDED", "This stock has been successfully added to your favorites!", "OKAY");
                successLabel.IsVisible = true;

                MessagingCenter.Send<StockData>(newStockData, "NewStockData");

            catch (WebException ex)
                await DisplayAlert("API FAILED","Unable to retrieve data for that symbol. Please check that you typed it correctly or try again later.", "GO BACK");
                successLabel.Text = "Unsuccessful due to API error";
                successLabel.TextColor = Color.Red;
                successLabel.IsVisible = true;

and here is my DataManager.cs class that gets the API and converts it to json:

public class DataManager
        //This class will be responsible for pulling data from remote API
        //And putting it into the stock data opjects and passing it back to normal UI classes
        //Create variables to use
        WebClient apiConnection = new WebClient();
        //Create a string to start API
        string startAPI = "<<ACCESS KEY REDACTED>>";
        string Symbols { get; set; }
        string ApiEndPoint
                return startAPI + Symbols;

        public DataManager(string symbolsToDownload)
            //make symbols equal to whatever gets passed in
            Symbols = symbolsToDownload;

        public async Task<StockData> GetStock()
            //Create a string representation of the downloaded data from ApiEndPoint
            string apiString = await apiConnection.DownloadStringTaskAsync(ApiEndPoint);

            //Create a JObject to store the apiString as a parsed JObject to get access
            //to the json formatted data
            JObject jsonData = JObject.Parse(apiString);

            //create another JObject
            JObject firstStock = (JObject)jsonData["data"][0];


            //Create a new StockData object
            StockData stockData = new StockData();
            stockData.StockName = firstStock["symbol"].ToString();
            //We need to get the string value and parse it as a Double to define the stock Data property
            stockData.OpenPrice = Double.Parse(firstStock["open"].ToString());
            stockData.ClosePrice = Double.Parse(firstStock["close"].ToString());
            stockData.HighPrice = Double.Parse(firstStock["high"].ToString());
            stockData.LowPrice = Double.Parse(firstStock["low"].ToString());
            stockData.Volume = Double.Parse(firstStock["adj_volume"].ToString());
            stockData.Exchange = firstStock["exchange"].ToString();
            stockData.TradingDay = DateTime.Parse(firstStock["open"].ToString());

            //return the new stock data object
            return stockData;

Am I just using my try catch the wrong way? Everything I find online, confuses me.. I’m still a student and learning so I apologize if this is a silly question. Please help me

if you paste your url into your browser

string startAPI = "<<ACCESS KEY REDACTED>>&symbol=AAPL";

you will get back this very friendly and explicit error message

    "code": "missing_access_key",
    "message": "You have not supplied an API Access Key. [Required format: access_key=YOUR_ACCESS_KEY]"

accesskey should be access_key

  1. Make sure that the value of access_key is transmitted correctly and the value is correct.
  2. Add a breakpoint in the first line of try to see where the error occurred.
  3. Print out “ex” in the catch to view the specific information of the error.