二进制文件上传在 Azure API 管理中不起作用

发布时间:2021-03-04 15:17

我有一个 dot net core 3 web api,它接受 IFormFile 作为输入并将二进制文件保存在数据库中。我已将 Swagger 添加到项目中以测试 api,它工作正常,也用 Postman 进行了测试。我在 APIM 中使用 OpenAPI 选项导入了这个 api。现在我在那里尝试了测试选项,但失败并显示此消息 "Failed to read the request form. Missing content-type boundary."。我在 Binary 中选择了 Request body 选项来上传文件并在请求标头中设置 Content-Type: multipart/form-data 但我收到此错误。如果 Swagger 和 Postman boundary 是自动设置的,有人建议从标题中删除 Content-Type: multipart/form-data,但结果是 500: Internal Server Error。有人可以帮忙吗?


    {
        "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
        "title": "One or more validation errors occurred.",
        "status": 400,
        "traceId": "someid",
        "errors": {
            "": ["Failed to read the request form. Missing content-type boundary."]
        }
    }

回答1