Play WS API Making nested requests - WSClient

I want to make two HTTP requests(POST) using play2 WSRequest where some information from the first response is send to the second request. I tried to do this in following manner to make sure second request is only triggers after the first one is completed. But I get Type mismatch: cannot convert from F.Promise to F.Promise error

public Promise<Result>  executeAPI(String apiName,JsonNode requestBody){

    WSRequest pcLoginRequest = ws.url("");
    pcLoginRequest.setHeader("X-x-Password", "xxxxx")
            .setHeader("X-x-Username", "xxxxx")
            .setHeader("X-x-Content-Type", "application/json");

    Promise<Result> myPromise ="").map(response -> {           


        WSRequest pcrequest = ws.url("" + apiName);
        pcrequest.setHeader("X-x-Token",ProApiSession.getInstanceOf().getProToeken() )
                .setHeader("X-x-Content-Type", "application/json");

        Promise<Result>  myPromise2 = -> {
                      return Results.ok(response2.asJson());

        return myPromise;


Can someone please suggest how to do nested request using WSRequest in play. (import* )


Java 8 type inference errors are bad at the best of times. Since the result of the lambda you're passing to the first map is Promise<Result>, what you're trying to assign to myPromise is Promise<Promise<Result>>. What you actually want to do is replace the map call with flatMap, which is so named because is "flattens" the nested promise to just be a single promise.

Need Your Help

LWJGL Vertex and Fragment Shaders Wont Compile (Error CO206)

java opengl glsl shader lwjgl

I have been interested in learning OpenGl for a while. However every time I start working with it, I get the same error when compiling my shaders. This is the error code that is spits out.

Is it possible to disable both debugger visualization and ToString() invocation in all the debugger views of VS2008?

visual-studio-2008 tostring debuggervisualizer

My project depends on a 3rd party assembly which defines debugger visualizers for some of its types. Usually this is totally fine, but some types have lazy logic, which becomes eager once the data is