0

I have the following method in my Rest requests handler

def get_Game(String gameId){
    def gameInfo
    http.request(Method.GET, ContentType.XML){
        uri.path = gamePath
        uri.query = [id : gameId]
        response.'200' = { resp, reader ->
            gameInfo =  reader.item
        }
        response.'202' = {
            println 'retry'
        }
    }
    return gameInfo
}

The response status for this request is 200 if data is retrieved or 202 when the request is queued and I need to keep retrying until the status is 200.

Is there anyway to retry a request while response code is 202?

  • How about adding `return` statement here: `gameInfo = reader.item` and calling the same function again recursively. – Shmuel Jun 02 '22 at 14:44
  • 1
    Thanks, @Shmuel. Even though it is a fit solution for my problem I wonder if there is any more "elegant" solution. In python you can set the retry strategy of a connection request, so you can define timeouts, number of retries and so. – Marta Martínez Jun 04 '22 at 20:12

0 Answers0