title: {"Unexpected character encountered while parsing value: <. Path '', line 0, position 0."} in google analytics api
body: <p>I’m using the sample <a href="https://github.com/LindaLawton/Google-Dotnet-Samples/tree/master/Google-Analytics" rel="nofollow">code</a> from GitHub.</p>
  
  <pre><code>            #region code
  
              AnalyticsService service;
  
                         // Service account Authentication 
              String SERVICE_ACCOUNT_EMAIL =" ";// removed the account email
              string SERVICE_ACCOUNT_KEYFILE = @"C:\Projects\Test\TMBWebsite-7f016e7c3562.p12";
              service = DaimtoAnalyticsAuthenticationHelper.AuthenticateServiceAccount(SERVICE_ACCOUNT_EMAIL,SERVICE_ACCOUNT_KEYFILE);
  
  
  
  
              //////Get account summary and display them.
              foreach (AccountSummary account in DaimtoAnaltyicsManagmentHelper.AccountSummaryList(service).Items)
              {
                  // Account
                  Console.WriteLine("Account: " + account.Name + "(" + account.Id + ")");
  
                  foreach (WebPropertySummary wp in account.WebProperties)
                  {
  
                      // Web Properties within that account
                      Console.WriteLine("\tWeb Property: " + wp.Name + "(" + wp.Id + ")");
  
  
                      //Don't forget to check its not null. Believe it or not it could be.  
                      if (wp.Profiles != null)
                      {
  
                          foreach (ProfileSummary profile in wp.Profiles)
                          {
                              // Profiles with in that web property.
                              Console.WriteLine("\t\tProfile: " + profile.Name + "(" + profile.Id + ")");
                          }
                      }
                  }
              }
  
              #endregion
  </code></pre>
  
  <p>//Authenicate service</p>
  
  <pre><code>        if (!File.Exists(keyFilePath))
          {
              Console.WriteLine("An Error occurred - Key file does not exist");
              return null;    
          }
  
          string[] scopes = new string[] { AnalyticsService.Scope.Analytics,  // view and manage your analytics data
                                           AnalyticsService.Scope.AnalyticsEdit,  // edit management actives
                                           AnalyticsService.Scope.AnalyticsManageUsers,   // manage users
                                           AnalyticsService.Scope.AnalyticsReadonly};     // View analytics data            
  
          X509Certificate2 certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);
         // X509Certificate2 certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
          try
          {
              ServiceAccountCredential credential = new ServiceAccountCredential(
                  new ServiceAccountCredential.Initializer(serviceAccountEmail)
                 {
                     Scopes = scopes
                 }.FromCertificate(certificate));
  
              // Create the service.
              AnalyticsService service = new AnalyticsService(new BaseClientService.Initializer()
              {
                  HttpClientInitializer = credential,
                  ApplicationName = "Analytics API Sample",
              });
              return service;
          }
          catch (Exception ex)
          {
  
              Console.WriteLine(ex.InnerException);
              return null;
  
          }
  </code></pre>
  
  <p>#region Account Summaries</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
      /// Documentation: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list
      /// &lt;/summary&gt;
      /// &lt;param name="service"&gt;Valid authenticated Analytics Service&lt;/param&gt;
      /// &lt;returns&gt;List of Account Summaries resource - https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries&lt;/returns&gt;
      public static AccountSummaries AccountSummaryList(AnalyticsService service)
      {
  
          //List all of the activities in the specified collection for the current user.  
          // Documentation: https://developers.google.com/+/api/latest/activities/list
  
          //ManagementResource.AccountSummariesResource.ListRequest list = service.Management.AccountSummaries.List();
          ManagementResource.AccountSummariesResource.ListRequest list = service.Management.AccountSummaries.List();
          list.Alt = ManagementResource.AccountSummariesResource.ListRequest.AltEnum.Json;
          list.MaxResults = 1000;  // Maximum number of Account Summaries to return per request. 
  
          AccountSummaries feed = list.Execute();
          List&lt;AccountSummary&gt; allRows = new List&lt;AccountSummary&gt;();
  
          //var getRequest = settingsService.Groups.Get("samplegroup@example.com");
          //getRequest.Alt = "json";
          //var settings = getRequest.Execute();
  
          //// Loop through until we arrive at an empty page
          while (feed.Items != null)
          {
  
              allRows.AddRange(feed.Items);
  
              // We will know we are on the last page when the next page token is
              // null.
              // If this is the case, break.
              if (feed.NextLink == null)
              {
                  break;
              }
  
              // Prepare the next page of results             
              list.StartIndex = feed.StartIndex + list.MaxResults;
              // Execute and process the next page request
              feed = list.Execute();
  
          }
  
          feed.Items = allRows;
  
          return feed;
  
      }
      #endregion
  </code></pre>
  
  <p>AccountSummaries feed = list.Execute(); 
  is throwing an exception :{"Unexpected character encountered while parsing value: &lt;. Path '', line 0, position 0."} in  google analytics api </p>