I recently started creating a ASP.net Web API
For some reason I keep receiving this error when viewing the auto generated help documentation:
This is for a POST method
Samples show up fine for application/json and application/xml
I'm not quite sure but the application/-x-www-form-urlencoded keeps showing up
I've googled the error quite a bit but can't quite find what might be causing this
I truly appreciate any help that can be provided, also please let me know if you have any questions.
This is an expected behavior. HelpPage sample generation uses the actual formatters present on the HttpConfiguration to 'write' the sample objects. FormUrlEncodedMediaTypeFormatter cannot 'write' any type, hence HelpPage cannot generate samples for it. As a workaround you could explicitly supply a sample for a particular type (as shown in the Areas\HelpPage\App_Start\HelpPageConfig.cs's commented code).
config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable<string>));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With