title: Get integer list from a webapi
body: <p>How can I get an List from a WebApi?</p>
  
  <p>So far I have the Api method:</p>
  
  <pre><code>    public IList&lt;int&gt; GetKeywordIdsById([FromBody]string id)
      {
          try
          {
              if (string.IsNullOrEmpty(id))
              {
                  return null;
              }
              else
              {
                  return _categoryService.GetKeywordIdsById(Convert.ToInt32(id));
              }
          }
          catch
          {
              return null;
          }
      }
  </code></pre>
  
  <p>How can I invoke it and extract the List ?</p>
  
  <p>So far I call it like this but Result is from type String, so how can I convert it to List?:</p>
  
  <pre><code>public List&lt;int&gt; GetKeywordIdsById(int id)
  {
      try
      {
          using (var client = new HttpClient())
          {
              client.BaseAddress = new Uri(API_BASE_URL);
              client.DefaultRequestHeaders.Accept.Clear();
              client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
              return client.GetAsync("api/category/getkeywordidsbyid/" + id).Result.Content.ReadAsStringAsync().Result;
          }
      }
      catch (Exception e)
      {
          logger.Log(LogLevel.Info, e);
  
          return null;
      }
  }
  </code></pre>