How to POST both JSON and XML data at same time using body- form data in .NET core Web API? any sample example ?
How to post both JSON and XML data at same time using body- form data?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Farhan AhmedRank #73 · 25K reputationPosted Sep 18, 2021, 2:05 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Sep 18, 2021, 2:50 PM EDT
you can design the API to accept both types as shown below but HTTP doesn't allow 2 content types at the same time, so you will have to make 2 requests.
[HttpPost("post.{format}"), FormatFilter] public int Post([FromBody]Employee employee) { // do yr work } http://localhost:1234/api/employees/Post.json http://localhost:1234/api/employees/Post.XML