I'm currently developing a REST web service using Web API.
Now I am trying to receive stream file and object through the post.
When I sent it without the JobPosition object I received the file correctly, also when I sent the JobPosition without the file I received the JobPosition correctly.
But when I sent the stream file and the object through the postman I receive the error.
I would appreciate your help to understand if this is possible, and if so, the direction that will help me.
public class JobPosition
{
public int Id { set; get; }
public string Title { set; get; }
}
[HttpPost]
[Route("Job")]
public async Task<bool> Post(JobPosition job)
{
var multipartMemoryStreamProvider = new MultipartMemoryStreamProvider();
await Request.Content.ReadAsMultipartAsync(multipartMemoryStreamProvider, new CancellationToken());
var stream = await multipartMemoryStreamProvider.Contents[0].ReadAsStreamAsync();
// implementaion
return true;
}
I tried all the possible combinations with the Content-Type with no success.