0

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 parameter inside the Body.

The problem is that I want the parameter being used to still be "Password" when placed in the body. Is this possible?

public class NameModel
{
    public string UserName { get; set; }

    [JsonProperty(PropertyName = "Password")]
    public string Psswd { get; set; }
}

This is inside my ApiController:

public object Login([FromBody]NameModel nameModel) {}
Marco
  • 22,856
  • 9
  • 75
  • 124
Kate Lastimosa
  • 169
  • 2
  • 15

1 Answers1

0

Have you tried removing [FromBody] and also including

[JsonProperty("Password")] public string Psswd { get; set; }

instead of:

[JsonProperty(PropertyName = "Password")] public string Psswd { get; set; }

When I removed PropertyName = in the JsonProperty attribute it worked fine for me.

kibblator
  • 41
  • 4