title: Business Central APIConnect With Xamarin Forms using Azure AD
body: <pre class="lang-cs prettyprint-override"><code>public class EmployeeAbsenceService
  {
      private HttpClient _client;
      private readonly string webAPI = &quot;https://xxxxxx&quot;;
  
      public async Task&lt;ObservableCollection&lt;EmployeeAbsence&gt;&gt; GetData()
      {
          var uri = new Uri(webAPI);
          var myToken = await SecureStorage.GetAsync(&quot;AccessToken&quot;);
  
          HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, uri);
          message.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(&quot;bearer&quot;, myToken);
          try
          {
              HttpResponseMessage response = await _client.SendAsync(message.ToString());
              if(response.IsSuccessStatusCode)
              {
                  var content = await response.Content.ReadAsStringAsync();
                  return JsonConvert.DeserializeObject&lt;ObservableCollection&lt;EmployeeAbsence&gt;&gt;(content);
              }
          }
          catch(Exception ex)
          {
              System.Diagnostics.Debug.WriteLine(ex.ToString());
          }
          return null;
      }
  }
  </code></pre>
  <p>I access the token by using securestorage, it's working fine.</p>
  <p>I'm trying to get the data from business central, but the error message:</p>
  <blockquote>
  <p>System.NullReferenceException: Object reference not set to an instance of an object</p>
  </blockquote>