【问题标题】:Difficulties sending multipart/form-data request via Postman通过 Postman 发送多部分/表单数据请求的困难
【发布时间】:2018-09-15 09:31:29
【问题描述】:

拜托,这是您关心的问题:我想知道如何使用 postman 查询如下代码中定义的 Web 服务以进行测试。 PS:我无法更改方法签名

我有这样的网络服务:

@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();
}

这是我的配置图片:

enter image description here enter image description here

【问题讨论】:

标签: java rest postman


【解决方案1】:

要调用该服务,您需要传递 requestId,如下所示:

http://localhost:8080/uploadOpenAccountRequestFiles/requestId-value-here

要发送文件等 MultiPart 数据,您需要在 Postman 的正文部分中选择表单数据选项,然后通过选择文件下拉菜单来选择文件。另外,请确保为请求设置适当的标头。

查看下面的 stackoverflow 答案了解更多详情:

Tool for sending multipart/form-data request

【讨论】:

    猜你喜欢
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    • 2018-03-05
    • 2020-06-18
    • 2016-08-18
    • 2016-11-11
    • 2017-01-22
    相关资源
    最近更新 更多