When dealing with the HttpRequestMessage, does the Content field always have to be non-null? If yes, then what If I want to send an empty body? How would one specify that?
For example, with a DELETE or GET request.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It definitely should allow an empty content. As you quite rightly point out, DELETE and GET never have content bodies, and there’s no strict requirement to have one for POST either.
I usually use HttpClient, and just use an empty StringContent, e.g.