What I want is, API which takes email Id as a request object & check whether that email Id is present in Database or not.If email id is present Api will return true as a response else false.
What I have Done is:-
I have define one of the route for Emaiid as follow:-
config.Routes.MapHttpRoute(
name: "ApiEmailId",
routeTemplate: "api/{controller}/{action}/{email}",
defaults: null,
constraints: new { name = @"^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))+$" }
);
I have also tried this :-
config.Routes.MapHttpRoute(
name: "ApiEmailId",
routeTemplate: "api/{controller}/{action}/{email}",
defaults: null,
constraints: new { name = @"^[a-z]+$" }
);
Also I have written actionresult as follow:-
public IHttpActionResult GetEmailID(string email)
{
//New action condition
//To get employee records
var tblCountryName = from a in db.tblEmployeeRecords
where a.userName == email
select a;
if (tblCountryName == null)
{
return NotFound();
}
return Ok(tblCountryName);
}
When i Hit the API using Postman:-
url:-
GET http://localhost/api/tblEmployeeRecords/GetEmailID/firstname.lastName@companyname.onmicrosoft.com
error, I am getting :-
<h3>HTTP Error 404.0 - Not Found</h3>
<h4>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h4>
</div>
<div class="content-container">
<fieldset>
<h4>Most likely causes:</h4>
<ul>
<li>The directory or file specified does not exist on the Web server.</li>
<li>The URL contains a typographical error.</li>
<li>A custom filter or module, such as URLScan, restricts access to the file.</li>
</ul>
</fieldset>
Please kindly help me, Where I am wrong, what will be solution for this?