0

Here is my method It will take only one parameter . But I want user whaterver add in request body I need to save in logging.

[HttpPost]
[LogAPIUser]
public async Task<JsonResult> GameDetail(long game)

Here is my Postman request enter image description here

In ActionExecutingContext I have got only one action parameter

enter image description here

How can I get all body request data? If anyone have idea please let me know

Thanks in advance.

burnsi
  • 6,194
  • 13
  • 17
  • 27
Chmn
  • 11
  • 5

1 Answers1

1

https://learn.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api states that:

At most one parameter is allowed to read from the message body.

The reason for this rule is that the request body might be stored in a non-buffered stream that can only be read once.

You can try to look at this question: WebAPI Multiple Put/Post parameters

  • basically, you read the whole body, and get your elements out of it.

something in the effect of

[HttpPost]
public string MyMethod([FromBody]JObject data)
{
    long game = data["game"].ToObject<Long>();
    long rer = data["rer"].ToObject<Long>();
}

(did not try code, might be buggy)