gpt4 book ai didi

Test Spring Boot Multipart API End Point using Postman(使用邮递员测试Spring Boot多部分API端点)

转载 作者:bug小助手 更新时间:2023-10-25 11:04:13 26 4
gpt4 key购买 nike



I am trying to build an api end point to receive formdata along with Image file. I have a Spring Boot end point shown below:

我正在尝试构建一个API端点来接收表单数据以及图像文件。我有一个Spring Boot端点,如下所示:


    @PostMapping("/user/personUpload")
public ResponseEntity<BaseResposeModel> personUploadWithImage(@RequestParam("person") PersonModel person, @RequestParam("personImage") MultipartFile file) throws IOException{
.................

}
~~
How do I test this from postman. I always get 404 resource not found error.

[!This is the screenshot of Postman for testing the end point.][1]][1]


[1]: https://i.stack.imgur.com/DjgGH.png

更多回答

If you are encountering a 404 error when testing your Spring Boot multipart API endpoint using Postman, it indicates that Postman cannot find the resource at the specified URL. Ensure that the URL you're using in Postman matches the endpoint mapping in your Spring Boot application. If your Spring Boot application has a base path or context path configured, make sure you include it in the URL. Also, make sure your Postman request is correctly configured to send the data as multipart/form-data and that the field names (person and personImage) match the @RequestParam names in controller method.

如果在使用Postman测试您的Spring Boot多部分API端点时遇到404错误,则表明Postman在指定的URL上找不到资源。确保您在Postman中使用的URL与您的Spring Boot应用程序中的端点映射匹配。如果您的Spring Boot应用程序配置了基本路径或上下文路径,请确保将其包含在URL中。此外,请确保您的邮递员请求被正确配置为以多部分/表单数据的形式发送数据,并且字段名称(Person和Person Image)与控制器方法中的@RequestParam名称匹配。

You can also try this

你也可以试试这个

Thanjks . My problem is solved I has an error in matching url with end point. But I have another issue which I will raise separately.

谢谢我的问题解决了我有一个错误匹配的网址与终点。但我还有另一个问题,我将单独提出。

优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com