I have a list of around 1000 applicants. I have to call an API to delete them each individually using the below inside a for loop. When I run this code in a console app it works fine. When I run this code from a scheduled webjob it runs runs for the first 2 then HttpWebResponse
times out.
WebRequest request = WebRequest.Create(url + "/applicants/" + applicants["id"]);
request.Method = "DELETE";
request.Headers.Add("Authorization", "Token token=XXX");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if ((int)response.StatusCode == 204)
{
Console.WriteLine(applicants["id"] + " marked for deletion");
counter++;
}
Is there something on the webjob preventing multiple requests?
I fixed this issue with:
response.Close();