Jamie Jamie - 9 months ago 88
C# Question

C# Restsharp not working

I'm trying to make a post request with RestSharp.

var request = new RestRequest("login", Method.POST);
request.AddParameter("email", email);
request.AddParameter("password", password);

List<RestResponse> result = null;

var asyncHandle = client.ExecuteAsync<result>(request, response => {

But I receive the error:

'result' is a variable but it's used like a type.

What am I doing wrong?


This won't compile, as you've noticed.

Without knowing anything about your model, or the response coming back, I'm going to take a guess that this may get you closer to where you want to be.

List<RestResponse> result = null;

result = client.ExecuteAsync<List<RestResponse>>(request, response => {

This at least compiles, because we're passing a type into ExecuteAsync rather than a variable