'Google maps api Nearby Search gives: 'Error 500: Internal Server Error' in C#

I am using React to attempt to call a Nearby Search using Google Maps API. I have my own API key, which has the proper enabled API's, and when i try to get the contents of the Nearby Search's URL using C#, i get the error 500. All i am trying to do, is reach that nearby search URL to get JSON data and write that JSON data to a file. Any ideas? Cant attach images yet, so I will just copy and paste the code.

 public ActionResult<string> GetGAPI() 
       {
         WebClient web1 = new WebClient();
        string data = web1.DownloadString(GOOGLE API URL);
        writeResource(data);
        Console.WriteLine(data);
        return Ok(data);
    }`enter code here`
    private static void writeResource(string data)
    {
         string filePath = ("C:/Users/REDACTED/OneDrive/Documents/Senior Project/Project Onward/react-app/FILENAME");
        System.IO.File.ReadAllText(filePath);
        System.IO.File.WriteAllText(data, filePath);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source