我试图用curl测试我的端点并得到415:
curl -X POST "http://localhost:5001/api/countries/import" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer "$API_TOKEN \
--data @/D:/_countries.json
响应:
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","status":415,"traceId":"0HLTFOME7T990:00000001"}
这是我的.net核心终结点:
// POST api/countries/import
[HttpPost]
[Route("[action]")]
public async Task<IActionResult> Import(IFormFile file)
{
...
}
顺便说一句,我在邮递员中使用此端点没有问题,尽管它生成的代码对我不起作用(响应是相同的):
curl --location --request POST 'http://localhost:5001/api/countries/import' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {token here}' \
--form 'file=@/D:/_countries.json'
PS我正在使用Windows 10和git bash运行脚本。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句