收到错误-找不到内容类型“应用程序/文本”的输出格式化程序以写入响应

问题描述 投票:0回答:1

这是我如何调用我的API

 curl -X POST "http://<IP>:8015/DataProcessing/v1/DataProcessing/PostDatasync" -H  "accept: */*" -H  "Content-Type: text/json" -d "sample"

这是我的服务器端API代码

[HttpPost]
[Route("PostDatasync")]
[Produces("application/text")]
[SwaggerOperation("PostDatasync")]
[SwaggerResponse(204, "No content", null)] 

public async Task<IActionResult> PostDatasync(
[Required] [FromBody] string data)
 {
  _logger.LogInformation($"PostDataAsync() ." + data)           

   return NoContent();
 }

2020-02-19 03:59:04.011 +00:00 [警告] [Microsoft.AspNetCore.Mvc.Infrastructure.DefaultOutputFormatterSelector] [{Id:1}]找不到内容类型'“ application / text的输出格式化程序“'来撰写回应。

我在邮递员工具中看到415 Unsupported Media Type状态。

c# api rest-client
1个回答
0
投票

您确定要您的端点以应用程序/文本格式返回响应吗?我找不到它作为普通类型。也许将您的Produces属性更改为application / json?

© www.soinside.com 2019 - 2024. All rights reserved.