Reputation: 576
I'm using ASPNET Boilerplate framework for developing my application, but I'm sure this is a WebAPI Specific issue. I'm consuming a Dynamic WebAPI function that is built upon the following Application Layer function.
On my Angular App I'm using the following code to POST data to the Dynamic API and eventually the Application Layer function.
var formDataObject = new FormData();
formDataObject.append('avatar', vm.group.avatar);
formDataObject.append('name', vm.group.name);
formDataObject.append('description', vm.group.description);
$.ajax({
url: abp.appPath + 'api/services/app/group/CreateGroup',
processData: false,
//contentType: false,
type: 'POST',
data: formDataObject
});
I receive the following error in my Chrome console:
{"message":"The request entity's media type 'application/x-www-form-urlencoded' is not supported for this resource.","exceptionMessage":"No MediaTypeFormatter is available to read an object of type 'InputGroup' from content with media type 'application/x-www-form-urlencoded'.","exceptionType":"System.Net.Http.UnsupportedMediaTypeException","stackTrace":" at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"}
I've tried the following solutions with no success:
All the solutions I've seen on the internet don't work for me.
Upvotes: 2
Views: 7468
Reputation: 576
Okay I solved this after many hours of debugging so if anybody else is facing the same problem can save time. This was NOT a WebAPI issue. WebAPI provides MediaTypeFormatters for 'application/x-www-form-urlencoded'. This issue was due to some implementation of Abp.WebApi package that was outdated. Update your aspnet boilerplate packages to Abp v1.0 release Sep 28, 2016. Fix the broken code. and recompile. This problem should be solved. Reach out to me if you're still having issues maybe I can help.
Upvotes: 2