I have a Web API 2.0 action that does the following:
[System.Web.Http.Route("api/wdretrievedata")]
[System.Web.Http.HttpGet]
public IHttpActionResult RetrieveUserData(string email)
{
var user = new WDUserData();
user.FirstName = "FirstName";
user.LastName="LastName";
user.PhoneNumber="PhoneNumber";
return Ok(user);
}
AS you can see, no errors are here. I run this in Postman and get results (omitted certain data for security):
I run this in my code via $.ajax like so:
$.ajax({
url: 'http://localhost:49352/api/wdretrievedata?email=myemail@gmail.com',
type: "GET",
async: true,
success: function (data) {
//never goes here
},
error: function (err) {
//always goes here
//err.statusText says 'error' and nothing else
alert(err.statusText);
}
});
The API call always returns in the error section and contains no data whatsoever. How do I get my API call to work via the $.ajax call like Postman? Thanks
If this helps, i've deployed my api to my web server. Troy this url to see what i'm getting: