![]() If you were sending via AJAX (where you could conceivably use JSON), then you should also be returning JSON or maybe PartialView, but not View or a redirect. However, if you do that, you can no longer receive traditional form posts, and in this context, that's what's going to be sent. First, this action is designed for a traditional HTML form post ( x-To test it in Postman, you should send the request as x-In order to receive JSON, your param would need to have the FromBody attribute applied to it ( TaskViewModel model). Var task = await _(id) įinally, as to the main problem from your question, there's two issues. Public async Task Update(long id, TaskViewModel model) You'll want to first retrieve the existing task from your database and then map the posted values onto that. While this is specifically for a create action, it's worth pointing out the subtle difference for an update. The mapping here is fairly straight-forward, but you may prefer to utilize a library like AutoMapper to handle this for you: _mapper.Map(model). Public async Task Create(TaskViewModel model) Then, you'll need to map from your view model to your entity class: There's no Id property, since it's not needed or desired, and the display names and error messages to be presented to the user are placed here only. Whereas the view model is concerned only with the view. The entity has only things that matter to the database ( here indicates that the column should be non-nullable). added "Entity" to the name to prevent conflicts with ``Īlso, note the division of responsibility. Then, your view model should only contain properties that you want to actually allow the user to edit, negating the need entirely for the Bind attribute, which should be avoided anyways. You should definitely be using a view model, but you should also have a separate entity class. This is actually an entity in this case, not a view model. First and foremost, why are you saving your view model to the database. "Description": "collate all the pending data" In TaskViewModel.cs I have: public class TaskViewModel My controller looks as follows: Ĭreate( TaskViewModel taskViewModel) Is there something that I should configure in my API, something else am I missing? When I pass the request from postman with this change I get 200 Ok status message but no data is being committed to the table in Sql Server. When I make a POST request from Postman to I get a 400 Bad Request Error (The request cannot be fulfilled due to Bad Syntax).After digging around I got a suggestion to comment out the ValidateAntiForgery token from the controller. Net Core 2.1 API that posts data using EF core. For more information about Oracle (NYSE:ORCL), visit have an. Oracle offers a comprehensive and fully integrated stack of cloud applications and platform services. My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts. To view full details, sign in with your My Oracle Support account.ĭon't have a My Oracle Support account? Click to get started! When clicking the Checkout button on the supplier's site, instead of returning to the iProcurement application and adding the punchout item to the iProcurement shopping cart, an error page appears. From the punchout supplier's web site, search for an item to request and add it to cart.Ĥ. This redirects the user to the supplier's web site.ģ. From the Shopping home page, click on a link to connect to a punchout store. Log in to Oracle Applications, using the iProcurement responsibility.Ģ. The issue can be reproduced at will with the following steps:ġ. Go to and look for the information you want.If you clicked on a link, it may be out of date.There might be a typing error in the address.The error page shows the following text: The webpage cannot be found In Internet Explorer, the title bar shows "HTTP 400 Bad Request".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |