Questions tagged [frombodyattribute]
60 questions
1
vote
2 answers
Creating Apex Class dynamically
I have created Apex Trigger through passing this parameters and link:
{
"Name" : "COTriggerEmp11",
"TableEnumOrId" : "employee__c",
"Body" : "trigger COTriggerEmp11 on employee__c (before insert) {system.debug('Record Inserted');}"
}
URL …

Curious_k.shree
- 990
- 2
- 18
- 37
0
votes
1 answer
HttpPost using FromBody with child objects
I have created a very simple API, which adds "Opportunities" to my database. That works fine, here is my controller method:
[HttpPost("addopportunity")]
public async Task AddOpportunityAsync([FromBody]Opportunity opp)
{
try
{
…

SkinnyPete63
- 597
- 1
- 5
- 20
0
votes
1 answer
Frombody in API controller does not properly pull data
In My code, I am trying to receive an API containing a JSON body containing data, I have designed a DataInfo Model class and used the [FromBody] function to translate the data.
My issue is that the data being pulled which I have formatted to be ints…

AHartwig99
- 1
- 2
0
votes
0 answers
java.lang.IllegalArgumentException: Multiple @Body method annotations found. (parameter #2) for method APIServiceDafater.sendFood
I send the following 3 parameters, but it is not sent
@POST("dafater/insertNewFoodsController")
Single sendFood(@Body List Foods,@Body Printer printer,@Query("warning") String warning);
server is asp.net
:( :( :(
0
votes
1 answer
ASP.NET Core 2.1 API POST body is null when called using HttpWebRequest, seems it can't be parsed as JSON
I'm facing a strange bug, where .NET Core 2.1 API seems to ignore a JSON body on certain cases.
I advised many other questions (e.g this one, which itself references others), but couldn't resolve my problem.
I have something like the following API…

OfirD
- 9,442
- 5
- 47
- 90
0
votes
1 answer
Attempting to pass empty body to POST endpoint with WebClient
I currently have an endpoint in my project:
[HttpPost("process")]
public IActionResult Process (string Val1, [FromBody] object Json)
{
//processing.....
Return Ok(...);
}
And on my client side I am trying to call this endpoint with…
user17336551
0
votes
0 answers
Is it possible to route and bind multiple content types to the same action?
From microsoft docs:
By default, model binding gets data in the form of key-value pairs
from the following sources in an HTTP request:
Form fields
The request body (For controllers that have the [ApiController] attribute.)
Route data
Query string…

alanextar
- 1,094
- 13
- 16
0
votes
2 answers
ajax doesn't pass array of objects to action
I am using ajax to pass Json data to an action in an asp.net core project.
I have an array of objects to pass
var AgentScores = [];
.
.
.
AgentScores.push({
AgentId: AgentId,
Fullname: Fullname,
Score : Score
});
$.ajax({
…
0
votes
0 answers
I have trouble posting json object from javascript
I have the react snippet:
const model = {
Code: 'somecode',
Elements: elements,
...more
}
apiPost(url, false, model)
.then(
)
Then:
export function apiPost(url, addAuth, json) {
return apiFetch('post', url, addAuth,…

nickornotto
- 1,946
- 4
- 36
- 68
0
votes
1 answer
.Net Core 2.1 ModelBinding not working when posting JSON
I have a .net core 2.1 solution comprising a web app, an API and a bunch of libraries.
I am trying to post JSON into a controller in the web project and it is not working - it appears that the properties that I am setting in the JSON are just being…

5NRF
- 401
- 3
- 12
0
votes
2 answers
ASP.Net Core required parameter binding fails to fail using FromBody
I'm developing an Asp.Net Core API.
My controller declaration
[ApiController]
public class BarController : Controller
{
...
}
My endpoint looks like this
[HttpPost, Route("bars")]
public async Task DoAsync(
[FromBody]…

balintn
- 988
- 1
- 9
- 19
0
votes
1 answer
Angular frontend, then C# Backend with Syntax errors: HTTP Controller receiving a JSON object in the body
Trying to get a basic model of my functions working.
Frontend (Angular): the body data will be JSON of this class:
class BackendParams {
listValues: any;
constructor( netList: any ) {
this.listValues = netList;
}
}
Then a function…

Yogi Bear
- 943
- 2
- 16
- 32
0
votes
0 answers
Using FromData vs FromBody attribute on api .net core
I have a .net core api written which integrates with swagger. Now I'm trying to make swagger page be user friendly but I am not willing to sacrifice security to do so. However, I don't have enough understanding and experience on the said topic and…

Bagzli
- 6,254
- 17
- 80
- 163
0
votes
1 answer
How to change the name of an object placed inside the [FromBody] attribute?
I have the class NameModel that will be used in the [FromBody] attribute. I NEED/am required to use Psswd instead of using the word "Password". [JsonProperty] attribute only works when serialized but it doesn't work if users use "Password" as the…

Kate Lastimosa
- 169
- 2
- 15
0
votes
2 answers
Reading dynamic object FromBody in WebAPI just doesn't work
I found a lot of info about this topic, but none of those sites and articles could solve my problem. I'm having a pretty simple method:
[HttpPost, Route("Diagnosis/{lkNo}/Tree/{nodeID:int}/Answer")]
public List AnswerTreeNode(string lkNo,…

André Reichelt
- 1,484
- 18
- 52