TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
renee Nay
NA
27
506
reading Json and Xml
Apr 15 2021 2:20 PM
I am running this code and it works great ..except when I am reading the xml. it reads the json but not the xml.
I was following the directions in this post Combine XML And Json Requests And Responses In ASP.NET Core Web API .
I am trying to give the user the function to send data in either json or xml.
I don't know how to get it to also read the xml in the post function or what I did wrong
here is my code
[[Route("api/[controller]")]
public class CancelController : Controller
{
[HttpGet("get.{format}"), FormatFilter]
public IEnumerable<BatchData> Get()
{
List<BatchData> cancel = new List<BatchData>
{
new BatchData { BatchNumber = "1"},
new BatchData { BatchNumber = "2"}
};
return cancel;
}
[HttpPost("post.{format}"), FormatFilter]
public BatchData Post([FromBody] BatchData cancel)
{
if (ModelState.IsValid)
{
return cancel;
}
else
{
return cancel;
}
}
]
Reply
Answers (
6
)
ASP.NET Core with ADO.NET | Dropdown lists for Create and Edit actions
problem with empty field in gridview when updating