Skip to content

Instantly share code, notes, and snippets.

@SibeeshVenu
Created August 15, 2021 14:39
Show Gist options
  • Save SibeeshVenu/bdbfdf46d94b59f919feb5e55dd5b75b to your computer and use it in GitHub Desktop.
Save SibeeshVenu/bdbfdf46d94b59f919feb5e55dd5b75b to your computer and use it in GitHub Desktop.
static async Task MyAPIPut(HttpClient cons)
{
using (cons)
{
HttpResponseMessage res = await cons.GetAsync("api/tblTags/2");
res.EnsureSuccessStatusCode();
if (res.IsSuccessStatusCode)
{
tblTag tag = await res.Content.ReadAsAsync<tblTag>();
tag.tagName = "New Tag";
res = await cons.PutAsJsonAsync("api/tblTags/2", tag);
Console.WriteLine("\n");
Console.WriteLine("\n");
Console.WriteLine("-----------------------------------------------------------");
Console.WriteLine("------------------Calling Put Operation--------------------");
Console.WriteLine("\n");
Console.WriteLine("\n");
Console.WriteLine("-----------------------------------------------------------");
Console.WriteLine("tagId tagName tagDescription");
Console.WriteLine("-----------------------------------------------------------");
Console.WriteLine("{0}\t{1}\t\t{2}", tag.tagId, tag.tagName, tag.tagDescription);
Console.WriteLine("\n");
Console.WriteLine("\n");
Console.WriteLine("-----------------------------------------------------------");
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment