I have a simple DTO object that looks like the following:
public class InstructionComponents
{
public int ApplicationNumber { get; set; }
public string FurtherComments { get; set; }
}
I want to be able to send this object through a POST request to an API endpoint that uses ASP.NET MVC. However I want to make sure that the data is sent using the body of the request, and isn't just appended to the url like in a GET.
This is simple enough using get requests and can be achieved with the following code.
var url = //endpoint url
using(var httpClient = new HttpClient())
{
var response = httpClient.GetStringAsync(url).Result;
return result;
}
I know that I can serialise the object to a JSON string using a library, but then what do I do with the string?