[英]Difficulties sending multipart/form-data request via Postman
please, this is y concern: I'll like to know how to query a web service defined as in the below code using postman for test purposes.拜托,这是你关心的问题:我想知道如何使用 postman 查询下面代码中定义的 web 服务用于测试目的。 PS: I can't change the method signature
PS:我无法更改方法签名
I have a web service like this:我有这样的 web 服务:
@POST
@Path("/uploadOpenAccountRequestFiles/{requestId}")
@Consumes({MediaType.APPLICATION_JSON,MediaType.MULTIPART_FORM_DATA})
public Response uploadOpenAccountRequestFiles(@PathParam("requestId") String requestId,
MultipartFormDataInput multipartFormDataInput)
throws JsonGenerationException, JsonMappingException, IOException {
initContext();
logger.info("DIGIBANK : uploadOpenAccountRequestFiles END: ");
String msge = "";
try {
digiBean.saveToserver(requestId, multipartFormDataInput);
} catch (Exception e) {
msge = e.getMessage();
e.printStackTrace();
}
org.af.webservice.Response resp = new org.af.webservice.Response(
request.getSession().getId(), "uploadOpenAccountRequestFiles", "",
msge.equalsIgnoreCase("OK") ? true : false, msge.equalsIgnoreCase("OK") ? false : true, "",
msge.equalsIgnoreCase("OK") ? true : false, "Boolean", msge);
logger.info("DIGIBANK : uploadOpenAccountRequestFiles END: ");
return Response.ok().entity(mapper.writeValueAsString(resp)).build();
}
this is are images of my configurations:这是我的配置图像:
enter image description here enter image description here在此处输入图像描述 在此处输入图像描述
For calling that service, you need to pass requestId like below: 要调用该服务,您需要传递requestId,如下所示:
http://localhost:8080/uploadOpenAccountRequestFiles/ requestId-value-here http:// localhost:8080 / uploadOpenAccountRequestFiles / requestId- value- 此处
For sending MultiPart data such as a file, you need to select form-data option in the body section in Postman and select the file by selecting the File dropdown. 要发送诸如文件之类的MultiPart数据,需要在Postman的正文部分中选择form-data选项,然后通过选择File下拉列表来选择文件。 Also, make sure to set the appropriate headers for the request.
另外,请确保为请求设置适当的标题。
Check the below stackoverflow answer for more details: 查看以下stackoverflow答案以获取更多详细信息:
Tool for sending multipart/form-data request 用于发送多部分/表单数据请求的工具
The steps of uploading a file through postman along with passing some input data along with the multipart request is very well discussed in below blog along with the screenshot.通过 postman 上传文件以及将一些输入数据与多部分请求一起传递的步骤在下面的博客以及屏幕截图中得到了很好的讨论。 In this blog, the api code is written in node js.
在这篇博客中,api 代码是用node js 编写的。 You can go through it once.
您可以通过它一次 go。 It may give some information.
它可能会提供一些信息。
https://jksnu.blogspot.com/2021/09/how-to-create-post-request-with.html https://jksnu.blogspot.com/2021/09/how-to-create-post-request-with.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.