I am trying to run multiple GET requests using RestSharp but it only runs one request and then stop. Can someone please suggest what I am doing wrong here?
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RestSharp;
namespace CertificatesAPI
{
[TestClass]
public class UnitTest2
{
[TestMethod]
public static void Reqres()
{
int[] userIDs = {1, 2, 3, 4, 5};
foreach (int ID in userIDs)
{
var client = new RestClient("https://reqres.in/api/users");
var request = new RestRequest(Method.GET);
request.AddParameter("id", ID);
IRestResponse response = client.Execute(request);
HttpStatusCode statusCode = response.StatusCode;
int StatusCode = (int)statusCode;
if (StatusCode == 200)
{
Console.WriteLine("SUCCESS");
Console.WriteLine(response.Content);
}
else
{
Console.WriteLine("Status Code: " + StatusCode);
}
Console.Read();
}
}
}
}
I created a Unit Test Project in Visual Studio and then created another project in the same solution to call this method Reqres and run this under Main method. I am a backend tester and new to C# and Visual Studio.