Run a job that request a url with windows authentication

I need to run this job but it fails with error 401 (not authorized)
this URL that I’m attempting to get response is the same site that I’m running hangfire and has windows authentication mode.
var Url = “https://some_url”;
var client = new WebClient();
client.Credentials = new NetworkCredential(ConfigurationManager.AppSettings[“Username”], ConfigurationManager.AppSettings[“Password”], “domain”);

I also tested the credentials and its correct.