Compilation error in code

I am following this.

In my code, I have following

pathCall("/api/hello/:id", this::hello),
pathCall("/api/hello/:id", this::useGreeting),
restCall(Method.GET, "/api/getEmpData?id, this::getData)

getData is defined as:

ServiceCall<NotUsed,Source<String,?>>getEmpData(String id);

This gives me error:

Cannot resolve method ‘restCall(com.lightbend.lagom.javadsl.api.transport.Method, java.lang.String, )’

What is causing this?

@mghildiy i do not think you can use restCall with GET method for websocket connection.
You should use namedCall or pathCall.

I do not know if it was your intention or not but using Source in request and/or response of a ServiceCall will indicate Lagom to use websocket as an underlying protocol.


Thanks for the reply.

In link I posted, restCall is used with GET, as:

restCall(Method.GET, “/order/:orderId/item/:itemId”, this::getItem)

I am also trying to do same.

In the example reaponse is not a Source<String,?> but Item

So does it mean Lagom doesn’t allow streaming via a REST GET API?

It does but you should use namedCall or pathCall instead of restCall with GET

1 Like