webclientbuilder.baseUrl(url)
.defaultHeaders(headers -> headers.addAll(requestHeader))
.build()
.post()
.uri("/uri")
.bodyValue(data)
.exchange()
.flatMap(response -> {
if(response.statusCode() == HttpStatus.UNAUTHORIZED){
//retry with updated token in header
}
})
//return bodyToMono of specific object when retry is done or if
//response status is 2xx
Any advice on how to deal with this is appreciated! As the comments say, I need to add the new token to the header before I retry the post request if there is a statusCode of UNAUTHORIZED, and if statusCode of 2xx, then return bodyToMono.