Skip to content

Instantly share code, notes, and snippets.

@saymowan
Created September 14, 2020 00:44
Show Gist options
  • Save saymowan/dc83a863e3d6689613f61c4b95b8b3a3 to your computer and use it in GitHub Desktop.
Save saymowan/dc83a863e3d6689613f61c4b95b8b3a3 to your computer and use it in GitHub Desktop.
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