Questions tagged [frombodyattribute]

60 questions
28
votes
3 answers

REST API: GET request with body

I want to implement a REST API and need a body on my GET requests. (Like discussed here: HTTP GET with request body) Are there http clients which are not able to send a body with a GET request? Fiddler is able to do it, although the message box is…
user437899
  • 8,879
  • 13
  • 51
  • 71
27
votes
3 answers

Reading FromUri and FromBody at the same time

I have a new method in web api [HttpPost] public ApiResponse PushMessage( [FromUri] string x, [FromUri] string y, [FromBody] Request Request) where request class is like public class Request { public string Message { get; set; } public…
kkocabiyik
  • 4,246
  • 7
  • 30
  • 40
13
votes
4 answers

How can I parse this XML (without getting "Root element is missing" or "Sequence contains no elements")?

This is an offshoot from this question Why is the HttpWebRequest body val null after "crossing the Rubicon"? which was answered (one hurdle is leapt), but the next hurdle trips me up. With this code: public async void…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
9
votes
3 answers

How to return invalid JSON message on POST using FromBody?

I am creating an ASP.Net 5 application with MVC 6, using .Net 4.5.1. I have a POST method that uses a FromBody parameter to get the object automatically. [HttpPost] public IActionResult Insert([FromBody]Agent agent) { try { var…
8
votes
4 answers

FromBody value get null

This is Asp.Net Webform application This is my POST method in my Apicontroller public void Post([FromBody]string value) { } I'm with fiddler post process. I did so experiment. But it did not. What is the problem. Can you help? I've tried it, I've…
Hakan Ertuğ
  • 159
  • 1
  • 1
  • 7
7
votes
5 answers

Why is my Web API controller action not deserializing child properties of child properties?

I'm sending a json payload in a PUT request to a web API controller action. The action in question has a signature that looks like this: public IHttpActionResult Post([FromBody]SaveThingRequest request) SaveThingRequest looks something like…
sonicblis
  • 2,926
  • 7
  • 30
  • 48
6
votes
2 answers

Post received by FromBody causes serializable error

Here's the basic setup, I have an asp.net core webapi controller (in c#) with a post function like so: [HttpPost] public ActionResult Post([FromBody] string Name) { //Do some processing with the "Name" argument... return Ok(…
Vance Palacio
  • 1,280
  • 12
  • 17
3
votes
2 answers

Passing list of objects in Postman POST request -Body

I have this syntax in API-HTTP POST request public IHttpActionResult SyncWealthItemsForAccount([FromBody] List wealthItems, Data.EnumerationsIntegration.IntegrationType integrationType, string accountGuidId) I want to test…
Sara N
  • 1,079
  • 5
  • 17
  • 45
3
votes
2 answers

OData V4 function FromBody parameter

This OData function does not deserialize the model parameter from the body. It deserializes as null as seen from response. Is there support for FromBody parameters in OData…
Chris Barrett
  • 516
  • 3
  • 12
3
votes
3 answers

C# Web API POST parameter FromBody is always null

I've been scouring the web for hours and tried many different solutions also described here on StackOverflow. I know similar questions have been asked before, but none of the answers or comments have worked for me. The problem: I have a .NET Web API…
Devvox93
  • 166
  • 1
  • 3
  • 14
3
votes
2 answers

How can I pass a moderately large volume of data to my Web API app?

I've got this code in a Web API Controller: [Route("{unit}/{begindate}/{enddate}")] [HttpPost] public void Post(string unit, string begindate, string enddate, [FromBody] string stringifiedjsondata) { List
2
votes
1 answer

ASP.NET Core Web API: how to assign value of null to a missing property in the request when parameter binding

Using .NET 6.0. When trying to bind a parameter to a body of the request, I want to assign a value of null to the properties that aren't included in the request. Consider the following: public class SomeRequest { [JsonProperty(PropertyName =…
2
votes
1 answer

How to hit a HttpPost-action with a parameter?

I have an API with a [HttpPost("InsertSomething")] public async Task InsertSomething(Guid id, [FromBody] MyModel model) { try { ... Guid somethingId = await _myService.Insert(id, enz..) and when I wanna calling this…
user1531040
  • 2,143
  • 6
  • 28
  • 48
2
votes
1 answer

Parsing [FromBody] JSON: model null

I'm trying to parse some json in my action which will then do things with it. However I keep getting null as my model instead of the filled out model. This is the json I'm trying to parse: { "sameLanguages":true, "sameDeadlines":true, …
nbokmans
  • 5,492
  • 4
  • 35
  • 59
2
votes
1 answer

WebApi [FromBody] parsing

I have an existing controller where [FromBody] is working as expect in HttpPost methods. When writing tests, I found it necessary to use a customer serializer in order to avoid a circular reference due to the parent object having a child that…
riqitang
  • 3,241
  • 4
  • 37
  • 47
1
2 3 4