0
votes

I am using the Play Framework and I am trying to make an HTTP request using the built in WS support. Whenever I try and make this HTTP request in a controller I get this error

error: cannot find symbol

for the code

public static Result foo(){
    return async(//ERROR ON THIS LINE FOR `async()`
        WS.url(GoogleStrategy.getTokenUrl).post(getTokenUrlParams).map(
            new F.Function<WSResponse, Object>() {
                    @Override
                    public Object apply(WSResponse wsResponse) throws Throwable {
                        return ok(wsResponse.asJson());
                    }
            }
        )
    );
}

This is odd because in all of the examples shown in the documentation, this seams to be the correct way to do what I wish to do.

1

1 Answers

3
votes

You were almost certainly looking at an old version of the documentation. async() is no longer needed.

The current version: https://www.playframework.com/documentation/2.3.x/JavaAsync

public static Promise<Result> foo(){
  return WS.url(GoogleStrategy.getTokenUrl).post(getTokenUrlParams).map(
    new F.Function<WSResponse, Result>() {
      @Override
      public Object apply(WSResponse wsResponse) throws Throwable {
        return ok(wsResponse.asJson());
      }
    }
  );
}