Questions tagged [frombodyattribute]
60 questions
2
votes
0 answers
Why does [FromBody] ignore model binders?
I'm working on an REST API in ASP.NET. One of the first things I made was a Model Binder for the model, binded with the model by a code like this:
[ModelBinder(typeof(MyModelModelBinder))]
public class MyModel { ... }
And used it in an…

Maurice Klimek
- 930
- 5
- 13
- 48
1
vote
0 answers
Asp.Net Core Razor Pages Ajax Post is Null using FromBody
I'm developing an Asp.Net (6.0) Razor Pages application. One of the pages needs to Post data using AJAX, however, the Post is always Null.
I have tried to use the previous related questions to this on Stackoverflow, but my problem still…

tcode
- 5,055
- 19
- 65
- 124
1
vote
1 answer
FromBody and FromQuery attributes fail for HttpPost, returns "One or more validation errors occurred"
Please see my c# core api code as following:
[HttpPost]
public bool Save([FromBody] string data,[FromQuery] ICollection list)
{
var result = true;
return result;
}
and angular post call as following:
postAction(data: any,…

rock
- 35
- 8
1
vote
1 answer
Ajax POST works with [FromForm] but not with [FromBody]
In my View I pass BookViewModel and I have a form which I am trying to create a Book with. I can perform this if I use the [FromForm] attribute but I am trying to understand how that differs from [FromBody]. Here are my models:
public class Book
{
…

stupidQuestions
- 81
- 11
1
vote
0 answers
AWP.Net Web API Post object always empty
I have read through this thread and none of the answers have been able to solve my issue.
I am attempting to post a simple POCO to a .Net Web API controller but no matter what is in the body, the parameter is always a default object, never…

Lewis Hamill
- 171
- 1
- 13
1
vote
1 answer
Is there a way to do nested model binding with the [FromBody] attribute?
I'm trying to do a POST request with a JSON object as the body. The JSON object contains nested types that are predefined models in a library I am using, but when I use [FromBody] attribute only the root model gets binded while the nested models are…

avenmia
- 2,015
- 4
- 25
- 49
1
vote
0 answers
JSON object inside object sent in POST request is not passed to C# method
I'm trying to pass parameters to a C# method through a post request. I have one C# object that contains all the fields I'm sending with the request and of them is a non primitive object I created. When I send a POST request with the object in a JSON…

Nexaspx
- 371
- 4
- 20
1
vote
0 answers
Why FromBody fill default value, but DeserializeObject throw an error when null value is passed(for not nullable datatype)?
I am creating POST API in .NET. I have following class.
public class Item
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
Following is the controller method.
1st approach:-…

yajiv
- 2,901
- 2
- 15
- 25
1
vote
1 answer
MVC Api Controller Method HttpPost not working
I am using Visual Studio 2013...
I am having some problems with Api Controller Method.
I understand the differences between HTTPGET, HTTPPUT, [FromUri] and [FromBody].
I have a simple Method, and I am testing all combination.
When I…

Diego
- 2,238
- 4
- 31
- 68
1
vote
1 answer
Json data passed as argument [FromBody] is Map to Class gives NULL
I have a following JSON String , which is passed as a input parameter of my Web-API.
I face trouble in accessing the multilevel JSON data , only NULL value is receiving in…

jidh
- 172
- 1
- 6
- 22
1
vote
4 answers
How to pass DataTable via FromBody to Web API POST method (C#)
I am successfully calling a POST method in a Web API app from a Winforms client that passes some parameters for a Stored Procedure.
I would prefer, though, to pass the results of the Stored Procedure (which I have to run on the client first) to the…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
1
vote
1 answer
Should I use "[FromBody]" values or custom params when responding to an HTTP Post call in a Web API app?
Is POST the right HTTP method/verb to use for telling the server which criteria to use to retrieve data and then save it locally?
I want to send an URL from a client (Windows Forms) app/util to my Web API app to tell it to retrieve data via a Stored…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
1
vote
0 answers
WebApi POST body not binding with FromBody
I've defined my ApiController's method like so:
public HttpResponseMessage Post([FromBody] string json)
The method is being called, but json is always null. I can see via Fiddler that what I'm passing is what I expect (hostname obviously edited…

Scott
- 163
- 2
- 11
1
vote
1 answer
Body part of POST Http request is null
I'm using AFNetworking framework to send some data to the .Net backend. I'm using POST:parameters:success:failure: method.
The .net backend is reading data using the FromBody attribute
[System.Web.Mvc.HttpPost]
public HttpResponseMessage…

Lukasz 'Severiaan' Grela
- 6,078
- 7
- 43
- 79
1
vote
0 answers
How can I pass a bunch of XML to a RESTful method from Android without putting it into the URL?
I know how to do this in C#, in fact I wrote a tip about it here, but I don't know how to accomplish it in Java/Android.
My code is this so far:
protected void doInBackground(String... params) {
String URLToCall =…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862