Articles → ASP .NET WEB API → Call Web API delete method using C#

Call Web API delete method using C#






Web API delete method




[HttpDelete]
public void DeleteAllFiles(string folderName) {
	if (File.Exists(string.Format(@"c:\{0}\InsertData.txt", folderName))) 
		File.Delete(string.Format(@"c:\{0}\InsertData.txt", folderName));

	if (File.Exists(string.Format(@"c:\{0}\InsertDataForEmployee.txt", folderName))) 
		File.Delete(string.Format(@"c:\{0}\InsertDataForEmployee.txt", folderName));
}





Console application




HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:40003/");
var response = client.DeleteAsync("api/PassParam?folderName=temp").Result;
if (response.IsSuccessStatusCode) {
	Console.WriteLine("Web API called successfully");
}
else 
	Console.WriteLine("There is some issue.");





Posted By  -  Karan Gupta
 
Posted On  -  Sunday, March 20, 2016

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250