i tried to send a basic file from my integration test project in C# to a web api . But i don't know why, each call i get an exception .
Json.JsonSerializationException : Error getting value from 'ReadTimeout' on 'System.Io.FileStream'
I found this property can't be read , so maybe that why my httpclient can't serialize it. So how can i send a file to a web api ?
This is my code from the client:
using (StreamReader reader = File.OpenText("SaveMe.xml"))
{
response = await client.PostAsJsonAsync($"api/registration/test/", reader.BaseStream);
response.EnsureSuccessStatusCode();
}
And my controller:
[Route("api/registration")]
public class RegistrationController : Controller
{
[HttpPost, Route("test/")]
public ActionResult AddDoc(Stream uploadedFile)
{
if (uploadedFile != null)
{
return this.Ok();
}
else
{
return this.NotFound();
}
}
Here the screenShot we can see , the property [ReadTimeout] can't be access.