Created
September 14, 2020 00:44
-
-
Save saymowan/dc83a863e3d6689613f61c4b95b8b3a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Newtonsoft.Json; | |
using NUnit.Framework; | |
using RestSharp; | |
namespace DataDriven_NetCore_NUnit | |
{ | |
public class APIHelpers | |
{ | |
//https://reqres.in/api/users | |
//Paste and check the json here - http://jsonviewer.stack.hu | |
//Only the "data" List Object is important to us! | |
public static dynamic GetUsersInfoAPI() | |
{ | |
var client = new RestClient("https://reqres.in"); | |
var request = new RestRequest("api/users", Method.GET); | |
request.AddHeader("content-type", "application/json"); | |
IRestResponse<dynamic> response = client.Execute<dynamic>(request); | |
return JsonConvert.DeserializeObject<dynamic>(response.Data["data"].ToString()); | |
} | |
}//end class | |
}//end namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment