title: Make Async Rest Request
body: <p>I am using RestSharp to make some Rest Requests on Windows Phone.</p>
  
  <p>But I am struggling to use  "Aync/await" with the functions that I use :</p>
  
  <p>For example with this function  : </p>
  
  <pre><code>   private  void Function() 
          {
              var client = new RestSharp.RestClient("https://exampleapi.com");
              client.Authenticator = [....]
              var request =  new RestSharp.RestRequest("/example.json", Method.GET);
              try
              {
                  client.ExecuteAsync(request, reponse =&gt;
                  {
                      if (reponse.StatusCode == HttpStatusCode.OK)
                      {
  
  
                // Operations with the json...
                      }
                      else
                      {
                          MessageBox.Show("Error");
                      }
                  });
              }
              catch (Exception error)
              {
                  MessageBox.Show(error.Message);
              }
          }
  </code></pre>
  
  <p>I tried to add the word <code>async</code> like this :</p>
  
  <pre><code>private async void restsharptest() 
              {
                  var client = new RestSharp.RestClient("https://exampleapi.com");
                  client.Authenticator = [....]
                  var request =  new RestSharp.RestRequest("/example.json", Method.GET);
                  try
                  {
                      client.ExecuteAsync(request, reponse =&gt;
                      {
                          if (reponse.StatusCode == HttpStatusCode.OK)
                          {
  
  
    var timeline =  JsonConvert.DeserializeObject&lt;List&lt;dynamic&gt;&gt;(reponse.Content);
                          }
                          else
                          {
                              MessageBox.Show("Error");
                          }
                      });
                  }
                  catch (Exception error)
                  {
                      MessageBox.Show(error.Message);
                  }
              }
  </code></pre>
  
  <p>Buth then when I try  add await :</p>
  
  <pre><code>var timeline = await  JsonConvert.DeserializeObject&lt;List&lt;dynamic&gt;&gt;(reponse.Content);
  </code></pre>
  
  <p>I get the following errors : </p>
  
  <blockquote>
    <p>Impossible to reach 'System.Collections.Generic.List </p>
  </blockquote>
  
  <p>and  : </p>
  
  <blockquote>
    <p>Operator 'await' can only be used in a lambda expression async. Mark
    this with lambda expression modifier 'async'.</p>
  </blockquote>
  
  <p>How can I use <code>async/await</code>  my  "Function1" ?</p>
  
  <p>EDIT : </p>
  
  <pre><code> client.ExecuteAsync(request, response  =&gt;
              {
                  if (response.StatusCode == HttpStatusCode.OK)
                  {
                      List_ = new List&lt;Myobject&gt;();
                      List_ = await Task.Factory.StartNew(() =&gt; JsonConvert.DeserializeObject&lt;List&lt;Myobject&gt;&gt;(response.Content));
                      tcs.SetResult(RefreshList_);
                  }
                  else
                  {
                      MessageBox.Show("Error");
                  }
              });
  </code></pre>
  
  <p>I have this error again :</p>
  
  <blockquote>
    <p>Operator 'await' can only be used in a lambda expression async. Mark
    this with lambda expression modifier 'async'.</p>
  </blockquote>
  
  <p>How can I solve this ?</p>