I can't figure out why I'm getting this. My ajax call the web api is below:
$.ajax({ url: '/api/FlossTotal/', type: 'GET', dataType: 'json', success: function (data, textStatus, xhr) { datasource = data; }, error: function (xhr, textStatus, errorThrown) { return; } });
Other controllers are working ok in the project.
500 would have to be a problem with the web API right. It's just basic as below:
public class FlossTotalController : ApiController
{
public List<FlossLinks> Get()
{
return DBFloss.GetTopAccounts(); //this is working fine
}
<b>Stack Trace:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
[InvalidOperationException: A callback parameter was not provided in the request URI.]
WebApiContrib.Formatting.Jsonp.JsonpMediaTypeFormatter.GetPerRequestFormatterInstance(Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType) +295
System.Net.Http.Formatting.DefaultContentNegotiator.Negotiate(Type type, HttpRequestMessage request, IEnumerable`1 formatters) +416
System.Web.Http.Results.NegotiatedContentResult`1.Execute(HttpStatusCode statusCode, T content, IContentNegotiator contentNegotiator, HttpRequestMessage request, IEnumerable`1 formatters) +137
System.Net.Http.HttpRequestMessageExtensions.CreateResponse(HttpRequestMessage request, HttpStatusCode statusCode, T value, HttpConfiguration configuration) +427
System.Net.Http.HttpRequestMessageExtensions.CreateErrorResponse(HttpRequestMessage request, HttpStatusCode statusCode, Func`2 errorCreator) +248
System.Net.Http.HttpRequestMessageExtensions.CreateErrorResponse(HttpRequestMessage request, HttpStatusCode statusCode, Exception exception) +171
System.Web.Http.<SendAsync>d__0.MoveNext() +924
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24
System.Web.Http.WebHost.<ProcessRequestAsyncCore>d__0.MoveNext() +418
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) +60
System.Web.HttpTaskAsyncHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +6
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9690164
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
My formatter config
public class FormatterConfig { public static void RegisterFormatters(MediaTypeFormatterCollection formatters) { var jsonFormatter = formatters.JsonFormatter; jsonFormatter.SerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; // Insert the JSONP formatter in front of the standard JSON formatter. var jsonpFormatter = new JsonpMediaTypeFormatter(formatters.JsonFormatter); formatters.Insert(0, jsonpFormatter); } }