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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Khoday AkileshPosted Oct 18, 2023, 9:21 PM
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;