Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Postman or Chrome display REST streaming output?

I have a REST server that is supposed to send plain text output as a stream, but when I perform the REST call with Postman or Chrome I get the whole output at once at the end of the process instead of getting a stream.

Here is my REST server, inspired from this article:

@GET
@Path("/stream-test")
@Produces(MediaType.TEXT_PLAIN)
public Response streamTest(){
  StreamingOutput stream = new StreamingOutput() {
    @Override
    public void write(OutputStream os) throws IOException, WebApplicationException {
      Writer writer = new BufferedWriter(new OutputStreamWriter(os));
      for (int i=1; i<=10; i++) {
        writer.write("output " + i + " \n");
        try {
          Thread.sleep(500);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
      writer.flush();
    }
  };
  return Response.ok(stream).build();
}

The output lines are all displayed at the same time. I would like to see an output each 500msec.

Is there something wrong with my implementation ?

Or are Postman and Chrome unable to display streaming outputs ?

Note: for technical reasons I still use Postman as a Chrome app.

like image 995
ThCollignon Avatar asked Jan 02 '18 07:01

ThCollignon


People also ask

Does Postman support streaming?

Postman doesn't support streaming api's at the moment! Show activity on this post.

How do I use Postman rest Client in Chrome?

In order to use the Postman Chrome app, you will first need to install Google Chrome browser. If you already have Chrome installed, head over to Postman's page on the Chrome Web store (https://chrome.google.com/webstore/detail/postman-rest-client-packa/fhbjgbiflinjbdggehcddcbncdddomop?hl=en), and click 'Add to Chrome'.

Is REST API streaming?

The difference between REST APIs and streaming APIs is: Streaming APIs updates are sent to the consumer when an event happens. REST APIs operate in a client-server architecture.


2 Answers

This post is quite recent; https://community.getpostman.com/t/stream-services-listener-how-to-test-in-postman/9714

Postman doesn't support streaming api's at the moment!

But as they've stated you can watch the issue on GitHub for updates ; https://github.com/postmanlabs/postman-app-support/issues/5040

like image 161
Capan Avatar answered Oct 31 '22 13:10

Capan


Getting the CURL request from POSTMAN is not enough in case you are streaming. In my case, needed to append the option

--no-buffer

and worked fine

like image 39
EigenFool Avatar answered Oct 31 '22 13:10

EigenFool