title: Webapi post method with enum input parameter
body: <p>Why do I get the error in the screenshot below when attempting to call a Web API method that takes a enum as an input parameter? How do I resolve this? </p>
  
  <p>It appears like the <code>messageDestinationType</code> is always null no matter what I do...</p>
  
  <p>I would prefer to keep the input type as an enum. I am newish to using web apis and can't understand how this is so difficult when a WCF handles this scenario perfectly</p>
  
  <pre><code>[JsonConverter(typeof(StringEnumConverter))]    
  public enum MessageDestinationType
  {
      None = 0,
      [EnumMember(Value = "SMS")]
      SMS = 1,
      [EnumMember(Value = "Email")]
      Email = 2,
      PushNotification = 3,
      UXP = 4,
      IntermediaryApp = 5,
      YouthApp = 6
  }
  
  
  
      [HttpPost, Route("ReadClientMessagesC")]
      public IHttpActionResult ReadClientMessagesC([FromBody]MessageDestinationType messageDestinationType)
      {
          var request = new ClientInboxRequest
          {
              Gcn = Gcn,
              ClientIpAddress = ClientIpAddress,
              CallingApplication = CallingApplication.Name,
              CallingApplicationVersion = CallingApplication.Version,
              CookieString = CookieString,
              HasPbUk = HasPbUk,
              HasIamIms = HasIamIms,
              HasPbZa = HasPbZa,
              HasSps = HasSps,
              HasWiUk = HasWiUk,
              HasWiZa = HasWiZa,
              LinkedGcns = LinkedGcns,
              RequestId = RequestId.ToString(),
              SsoProfiles = SsoProfiles.Select(x =&gt; x.Name).ToList()
          };
  
          MessageDestinationType messageDestination = (MessageDestinationType)messageDestinationType;
  
          return Ok(ClientMessageCenterHelper.ReadClientMessagesA(Gcn, messageDestination, request));
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/uDYiQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uDYiQ.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>Error message: {
        "Message": "The request is invalid.",
        "MessageDetail": "The parameters dictionary contains a null entry for parameter 'messageDestinationType' of non-nullable type 'API.Domain.ClientMessageCenter.MessageDestinationType' for method 'System.Web.Http.IHttpActionResult ReadClientMessagesC(API.Domain.ClientMessageCenter.MessageDestinationType)' in 'ID.ClientMessageCenter.Controllers.ClientMessageCenterController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."
    }</p>
  </blockquote>