We are using a service that sends data back to our API but they can only send XML. Our API returns Invalid Content Type. How can I setup the API to accept text/xml?
3 Answer(s)
-
0
Hi,
Abp removes all web api formatters expect Json formatter by default. You can override PostInitialize of your WebApi module and add a xml formatter.
Define a xml formatter like below,
public class CustomXmlFormatter : XmlMediaTypeFormatter { public ZeroXmlFormatter() { UseXmlSerializer = true; } }
public override void PostInitialize() { base.PostInitialize(); Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.Add( new CustomXmlFormatter() ); }
-
0
This only works for WebApi controllers. How can I make this work for Dynamic Controllers? For example, application/json is the only option that shows in Swagger but I want the option to send XML straight to the application layer through Swagger
-
0
Hi,
I think this is not possible right now. We have an issue regarding to this problem here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/301">https://github.com/aspnetboilerplate/as ... issues/301</a>.
If you can write a comment on this issue, we will give a higher priority to this problem.
Thanks.