尝试获取.net core 2.0 Web API HttpPost方法以使用xml输入。
预期结果:从Postman调用测试端点时,输入参数(以下代码中的xmlMessage)应具有从Postman HttpPost主体发送的值。
实际结果:输入参数为空。
在Web api项目的startup.cs中,我们具有以下代码:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.AddXmlDataContractSerializerFormatters();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{ …Run Code Online (Sandbox Code Playgroud)