0

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. PS: I can't change the method signature

I have a web service like this :

@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

Bizi
  • 69
  • 1
  • 8
  • Please check https://stackoverflow.com/questions/39037049/how-to-upload-a-file-and-json-data-in-postman/48054400#48054400 – Mahesh_Loya Apr 05 '18 at 14:24
  • Hello, thanks for your time, I tried to send the request like this: **http://192.168.202.210:8080/afb-fintech-api/rest/agentbanking/uploadOpenAccountRequestFiles/1**; then follow the example on the link your mentioned above, I received this error : HTTP 415 - Unsupported Media Type. – Bizi Apr 09 '18 at 15:41
  • please, I have no content type selected in headers.and in the body, just **form-data** and the file are selected – Bizi Apr 09 '18 at 15:45

2 Answers2

0

For calling that service, you need to pass requestId like below:

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

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. Also, make sure to set the appropriate headers for the request.

Check the below stackoverflow answer for more details:

Tool for sending multipart/form-data request

Rahul
  • 637
  • 5
  • 16
0

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. In this blog, the api code is written in node js. You can go through it once. It may give some information.

https://jksnu.blogspot.com/2021/09/how-to-create-post-request-with.html

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31237030) – cyberbrain Mar 10 '22 at 19:09