Retrying a code block on 401

I have this in lib.scala
def authenticate(username: String, password: String): ChainBuilder = {
.headers(getXAuthHeaders(username, password))

And this in run.scala
exec(lib.authenticate("${username}", userPassword )
.doIf(session => session(“auth_resp_code”).as[Int] == 401)) {
exec(lib.authenticate("${username}", userPassword))

I want to retry authenticate() if it fails for the first time with a 401. Furthermore i don’t want the 401 to be counted towards a KO.

Is this the correct approach?

And in the “doIf” block is there a way from me to see if it is being executed. How could i do something like println(“i am here”)


No need to reply…this works quite nicely :slight_smile: