Questions tagged [frombodyattribute]
60 questions
0
votes
1 answer
Web Api 2 [FromBody] Request Body On Post is NULL
All,
First, I know similar question has been asked umpteen times.
Second, I don't have 50 points (?!) to comment on any of them.
Third, I cannot use "Answer" to clarify my question on those posts - I get warning I will be banned from answering any…

griftopia
- 135
- 1
- 3
- 10
0
votes
1 answer
Posting Json to C# WebApi from React
I have a C# WebAPI action. I'm trying to post a string (but a json stringified string) to it using React.
For some reason I'm getting a 405 Method Not Allowed when the content type is aopplication/json. Urlencoded does get into PostTransaction, but…

Richard Whitehouse
- 679
- 3
- 14
- 28
0
votes
1 answer
Parameters dictionary contains null value, parameter present in request body
I'm trying to POST an enum to my WebAPI. The request body contains my parameter, and the controller has a [FromBody] tag. The problem is that I'm getting a null entry error even though the parameter is in the body.
I have the following api…

TomSelleck
- 6,706
- 22
- 82
- 151
0
votes
0 answers
FromBody parameter always null
There are many questions about this already on this forum. I have read them but i couldn't solve my issue, so I'll try and ask again in here.
I'm building an Angular + ASP Core app. I have used FromBody succesfully on other requests already, but for…

Lucas Arruda
- 533
- 1
- 8
- 15
0
votes
1 answer
Deserializing list objects, properties returning as null
I'm trying to POST data to an API which should accept a List. The size of the list is correct but the properties of the objects are blank.
public class UpdatePointHistory
{
string Tree { get; set; }
string FruitCount {…

TomSelleck
- 6,706
- 22
- 82
- 151
0
votes
0 answers
POST web api function to fetch BODY content in server side
I don't know its a stupid question or not ,for a clarification i am asking here.
Please advice on the following situation.
I came up with a situation, that [FromBody] attribute can be specified to decorate a parameter inside the function and get the…

jidh
- 172
- 1
- 6
- 22
0
votes
1 answer
Http PUT in body body: Bad request error, can't parse API token
I've got a big trouble parsing and sending request.
In body of request I have to send a token that I've already got successfully while authetification.
Here's a doc:
PUT /api/ver1/orders {"token" : String, "order" : Object}
And here's how I…

Andread Sze
- 51
- 4
0
votes
2 answers
Accepting application/xml content in webapi controller
I want to create an action that will accept application/xml content.
Basically I have created this so far.
namespace App.Areas.Test.Controllers
{
public class UserModel
{
public int Id { get; set; }
public string FirstName…

mko
- 6,638
- 12
- 67
- 118
0
votes
0 answers
usage of [From Body] in WebApi POST method gets NULL param
I am using [FromBody] in WebApi. And when I send requests to the POST method, the request doesnot have the passed body param.I receive a NULL in the param and also if I inspect the Request oibject it doesnt have the param in the Content. Tried using…
0
votes
1 answer
Parameter binding in WebApi post method
I am unable to bind data to the locationModel parameter in the following method. I looked at other posts but no solution seems to be working:
// Web Api Post method
public HttpResponseMessage Post(string vin, [FromBody] LocationModel…

Yasir
- 1,595
- 5
- 23
- 42
0
votes
1 answer
Why is the HttpWebRequest body val null after "crossing the Rubicon"?
I am trying to send the contents of an XML file from a handheld device (Compact Framework/Windows CE) to a Web API method in my server app like so (Client code):
public static string SendXMLFile(string xmlFilepath, string uri, int timeout)
{
…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
0
votes
1 answer
Working with Web Api and FromBody
I have my api which has a post method that looks like this:
// POST api/collections
public HttpResponseMessage Post([FromBody]Collection model)
{
if (!ModelState.IsValid)
return Request.CreateErrorResponse(HttpStatusCode.BadRequest,…

r3plica
- 13,017
- 23
- 128
- 290
0
votes
1 answer
Are [FromBody] and [FromUri] mutually exclusive?
I am passing this URI to my Web API…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
-1
votes
2 answers
.net core controllers - Add [FromBody] attribute to method or not?
I'm working on small web app, and when it comes about controllers / endpoints, I saw on many please that
some people are adding [FromBody] attribute in method parameters and some not.
I can't figure out what is the point ?
Here is the…

Roxy'Pro
- 4,216
- 9
- 40
- 102
-1
votes
2 answers
Am I being too explicit in passing an HttpWebRequest object to a Web API method?
I know (at least I think it's so) that when a Web API method is invoked, an HttpWebRequest is passed to it by the client. IOW, when a client sends something like this to invoke a Web API…

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