Jamie Jamie - 1 year ago 151
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download