Home > Blockchain >  get parameters from the request body along with a model
get parameters from the request body along with a model

Time:11-04

how to get the devId from the body, even using [FromBody], it keeps identifying the devId as a query

public async Task<ActionResult<Module>> PostModule([FromBody]Module module, long devId){}

CodePudding user response:

You can only have 1 argument with a FromBody applied.

From the documentation

Don't apply [FromBody] to more than one parameter per action method. Once the request stream is read by an input formatter, it's no longer available to be read again for binding other [FromBody] parameters.

If you want that devId being read from the body, you'll have to include that one as e.g. a property in your Module class.

  • Related