Subscribe Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security. Subscribe

All Response Codes possible

I had asked a previous question regarding how we can use the add_result_for_case API integration when using the suite project setup.

I realized there was not really a way to do this without further customization to the APIClient class. What I would like to do is add some more logic in there to handle response codes.

What I was able to achieve was to return all the runIds for a Test Plan. Now what I want to do is to iterate through these runIds, catch the 400 bad response and then iterate onto the next runId until one finally sticks and I stop attempting to POST results.

However what are all the response codes that can be returned? I would like to handle all of them individually. Thanks.

Old post found here: Add_result_for_case integration when there are sub suites with different runIds

Also for anyone wondering how can you can get a list of runIds associated with a Test Plan I made this method :

public static List<string> GetTestPlanRunIds(string planID)
{
    List<string> returnArray = new List<string>();

    APIClient client = new APIClient("...");
    client.User = "user";
    client.Password = "pass";

    JObject request = (JObject)client.SendGet("get_plan/" + planID);

    string response = request.ToString();

     JObject obj = JsonConvert.DeserializeObject<JObject>(response);

     foreach (JObject id in obj["entries"])
     {
         foreach (JObject run in id["runs"])
          {
               string returnable = (string)run["id"];
               returnArray.Add(returnable);
           }
       }

       return returnArray;
 }

Hi,
can you simply describe what you want to achieve?
I read your first post and was just wondering because you wrote about checking the forum first. You mixed up some things and I guess the way you decided to go won’t finally help you.

Just an offer.

Karsten

What things did I mix up? On the first post, I asked about a way to use the add_result_for_case API integration with test plans. Test Plans have multiple runIds associated with them therefore its not as straightforward.

On this one, I am wondering what all the API response codes are for testrail (400, 500, 200) and what they mean exactly.

I plan on customizing the APIClient class that is given when first setting up the gurock/testrail API integrations to handle 400s differently rather than just failing the test. I would like to know the other response codes and what they mean exactly so I can also make sure my customizations are handling them properly.

OK, it was just an offer.
Find the response codes for your endpoint in the doc.

200|Success, the test result was created and is returned as part of the response
400|Invalid or unknown test run or case
403|No permissions to add test results or no access to the project

Probably there are more, but you can start with these ones.

I completely missed this dropdown… This is exactly what I need - ty!