Hi, I have the below code which I am using to send JSON data to an API.I want to log the response/status code such as 200, 201, 400 etc. Please can someone assist me with how to log the response code?
Below is the current code:

Hi, I have the below code which I am using to send JSON data to an API.I want to log the response/status code such as 200, 201, 400 etc. Please can someone assist me with how to log the response code?
Below is the current code:

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Khoday AkileshRank #638 · 3.8K reputationPosted Oct 18, 2023, 5:21 PM EDT
HttpResponseMessage response = httpClient.PostAsync(URL, requestContent).Result;
Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
HttpContent content = response.Content;
string jsonContent = content.ReadAsStringAsync().Result;