I'm trying to call an api with 2 call using webclient.
The first call return a token
The second call use the token and ask some data.
How to do it??
I've tried with call the first and use GetToken().block()
but at runtime i have an error...
I've tried with :
GetToken().flatmap( x -> { GetDataRequest dataRequest = new GetDataRequest(x);
return this.GetData(dataRequest);
}
this is the first call:
private Mono<GetTokenResponse> GetToken() {
return
weblicent.post().uri("GetToken").contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8)
.syncBody(request)
.retrieve()
.bodyToMono(GetTokenResponse.class);
}
this.is the second call:
private Mono<GetDataResponse> GetData(GetDataRequest dataRequest) {
return
weblicent.post().uri("GetData")
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8)
.syncBody(dataRequest)
.retrieve()
.bodyToMono(GetDataResponse.class);