Ramco Ramco

Ramco Ramco

  • 438
  • 3.4k
  • 547.6k

Separate class or function

Dec 26 2022 3:33 AM

Hi

  In below code Token is generated . I want it to be a separate class or function. How it can be done

var client = new RestClient("api.nimbuspost.com/v1/users/login");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
var body = @"{" + "\n" +
@"    ""email"" : ""[email protected]""," + "\n" +
@"    ""password"" : ""T34!""" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
dynamic json = JsonConvert.DeserializeObject(response.Content);
string token = json.data;

Thanks


Answers (2)