User-1660589204 posted
Hi,
I am working on a console application and need to send a POST request to an API which gives me a response of ID. Please find the code below. I have an API call request code which is not working and has compile time errors. Please help me to make an
API request, get the response . Please check my code and help me with a solution.
public void FileChecker(FileDetails fileDetails)
{
HttpClient client = new HttpClient();
DirectoryInfo info = new DirectoryInfo(path);
info.GetFiles("*.trm");
DataTable FileDetailsTable = new DataTable();
System.Net.Http.HttpResponseMessage response = client
.PostAsync("https://project.au/api/v2/file/uploader", fileDetails);
response.EnsureSuccessStatusCode();
}
The compile time error is in the client.PostAsync call. The fileDetails variable shows: cannot convert from "Project.Model.FileDetails" to "System.Net.Http.HttpContent". Please help me with this.