简体   繁体   English

通过 Postman 发送多部分/表单数据请求的困难

[英]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.

相关问题 表单数据中的POSTMAN请求 - POSTMAN Request in form-data 如何在 postman 多部分/表单数据发布请求中将应用程序/json 数据与文件一起发送? - How to send application/json data along with file in postman multipart/form-data post request? 如何在邮递员的同一请求中发送多部分/表单数据和嵌套的json? - How to send multipart/form-data and nested json in the same request in postman? 骆驼发送多部分/表单数据请求 - Camel send multipart/form-data request 使用 ByteArray 请求 MultiPart/Form-Data - Request MultiPart/Form-Data with ByteArray 邮差多部分/表格数据错误:缺少开始边界 - Postman multipart/form-data error: Missing start boundary 如何在Java中使用Apache HttpComponents发送多部分/表单数据发布请求 - how to sending multipart/form-data Post Request in with use of Apache HttpComponents in java GAE使用SSL从blobstore发送包含多部分/表单数据和文件的发布请求 - GAE sending post request with multipart/form-data, file from blobstore with SSL Content-Length header 使用 WebClient 为 multipart/form-data 发送 POST 请求 - Content-Length header sending POST request with WebClient for multipart/form-data 使用Jersey发送多个文件:找不到multipart / form-data的MessageBodyWriter - Sending multiple files with Jersey: MessageBodyWriter not found for multipart/form-data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM