Send Email Through ASP.NET Web API GET Request

Usually we can send email field data through the body section in the HTTP POST request but in case of GET Request we should pass the email in API URI, so there is some changes need to be done in API URI by sending the Email.
Let us consider the example:
  1. //GET : api/Users/UserDetails/Email  
  2.        [HttpGet]  
  3.        [AllowAnonymous]  
  4.        [Route("UserDetails/{Email}")]  
  5.        public HttpResponseMessage UserDetails(string Email)  
  6.        {  
  8.            try  
  9.            {  
  11.                return Request.CreateResponse(HttpStatusCode.OK, Email,Configuration.Formatters.JsonFormatter);  
  12.            }  
  13.            catch (Exception ex)  
  14.            {  
  15.                return Request.CreateErrorResponse(HttpStatusCode.OK, ex.Message);  
  16.            }  
  17.        }  
From the above code its is clear we have created one API GET Action with Email 
GET: api/Users/UserDetails/Email

To overcome this issue we should modified the URI.
Instead of sending the request as  api/Users/UserDetails/Email we should use api/Users/UserDetails/Email/ , i.e we should add one more forward slash after email. 
GET: api/Users/UserDetails/Email/
I hope you enjoyed this blog. Your valuable feedback, question, or comments about this blog are always welcomed.  

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now