none
How to retry a failed request RRS feed

  • Question

  • With our webtests we'd like to retry a request if the error response code is >= 500.  I have a WebTest plugin that captures the PostRequest event and interrogates the response for this.  However I can't see that it's possible to then manually retry the failed  request, as it seems that all requests must originate from the .webtest itself (rather than from a plugin or code).

    Is it possible to do what I want?  These are legacy tests and I don't really want to have to edit every request and add a loop in every test (which would give me the ability to do what I want).

    TIA


    • Edited by bradders2011 Thursday, November 21, 2019 12:11 PM
    Thursday, November 21, 2019 12:09 PM

Answers

  • I can add code to the plugin where the PostRequest event is captured and use a WebRequest to manually send the request again, adding in headers and tokens, etc to the request:

    HttpWebResponse response;
    WebRequest webRequest = WebRequest.Create(e.Request.Url);
    
    //add headers etc
    response = (HttpWebResponse)webRequest.GetResponse();


    • Marked as answer by bradders2011 Thursday, November 21, 2019 2:29 PM
    Thursday, November 21, 2019 2:29 PM