Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误400-上传文件-简单请求_C#_Api_Web Services_Postman - Fatal编程技术网

C# 错误400-上传文件-简单请求

C# 错误400-上传文件-简单请求,c#,api,web-services,postman,C#,Api,Web Services,Postman,使用Postman,我试图向我的api发出POST请求(见下面的代码),以上载文件 我通过邮递员提出的请求: 守则: namespace Abbyytestrestapi.Controllers { [Route("api/Abbyy")] [ApiController] public class AbbyyController : ControllerBase { [HttpGet("Templates")] public Ac

使用Postman,我试图向我的api发出POST请求(见下面的代码),以上载文件

我通过邮递员提出的请求:

守则:

namespace Abbyytestrestapi.Controllers
{
    [Route("api/Abbyy")]
    [ApiController]
    public class AbbyyController : ControllerBase
    {
        [HttpGet("Templates")]
        public ActionResult  GetAvailableTemplates()
        {
            return Ok("test");
        }
        [HttpPost("ConvertFile/{templateKey}")]
        public ActionResult ConvertFile([FromBody] IFormFile pdfFile, string templateKey)
        {
            return Ok("hello");
        }
    }
}
但是我收到了一个错误400错误的请求。我不知道我做错了什么。。。你能帮我吗?:)

先谢谢你

[HttpPost("ConvertFile")]
    public ActionResult ConvertFile( [FromQuery] string templateKey , [FromBody] IFormFile pdfFile, string templateKey)
    {
        return Ok("hello");
    }
试着使用它


试着使用它

谢谢你的回答。我从代码中删除了第三个参数(我想你忘了删除它)。我现在执行该请求:“,表单数据中只有Pdfile键,我再次收到错误400谢谢您的回答。我从代码中删除了第三个参数(我想你忘了删除它)。我现在做这个请求:“,表单数据中只有Pdfile键,我再次收到错误400,可能是重复的,非常感谢您的链接!这解决了我的问题。很抱歉重复,我做了一些研究,没有发现。可能是重复的,谢谢你的链接!这解决了我的问题。很抱歉重复了,我做了一些研究,但没有发现。