0

I have the below code using which I am able to fetch the input Stream using getEntityStream().

    public String getRequestEntityStream(ContainerRequestContext requestContext) throws IOException {

        try (InputStream in = requestContext.getEntityStream()) {
            ByteArrayOutputStream out = new ByteArrayOutputStream(64 * 1024);
            IOUtils.copy(in, out);
            byte[] entity = out.toByteArray();

            // reset the input stream
            ByteArrayInputStream inNew = new ByteArrayInputStream(entity);
            requestContext.setEntityStream(inNew);

            String str = new String(entity);
            return str;
        }
    }

I am able to fetch the entity stream just fine as below:

Request Entity Stream :grant_type=password&username=system&password=system&client_id=xxx

The problem is the API call throws error as below after I read the Request Entity Stream. The error shows that grant_type is missing even though its clearly evident from the above data of "Request Entity Stream" that "grant_type" is present. May be the data type where I did "setEntityStream" isnt working. How can I just read the input stream without a need to convert to ByteArrayInputStream[]. What am I missing ? Thanks in advance.

UPDATE: I found some details here regarding the JBOSS env and I use the same. However, how do I get the input stream ?

enter image description here

jane
  • 211
  • 9
  • 30

0 Answers0