Google Analytics API UserActivity in .NET

I’ve been trying to access google analytics user activity via the Google.Apis.AnalyticsReporting.v4 library in .NET but it keeps returning a badRequest response and I’m a little stumped.

            SearchUserActivityRequest activityRequest = new SearchUserActivityRequest()             {                 ViewId = <<my view id>>,                 User = new User()                 {                     Type = "CLIENT_ID",                     UserId = <<some user identifier>>                 },                 DateRange = new DateRange()                 {                     StartDate = "2020-07-07",                     EndDate = "2020-07-08"                 },                 PageSize = 100             };              var analyticsService = GetAnalyticsReportingServiceInstance(ConfigurationManager.AppSettings["KeyFileName"]);              SearchRequest searchRequest = analyticsService.UserActivity.Search(activityRequest);              SearchUserActivityResponse response = searchRequest.Execute(); 

The full response is:

Message[CLIENT_ID: <<some user identifier>> not found.] Location[ - ] Reason[badRequest] Domain[global]

I can’t find any examples at all for this part of the API in .NET and I wonder if anyone can point me in the right direction. Thanks!

Add Comment
1 Answer(s)

This error message quite literally means that the client id specified in the request could not be found. It might be useful to do troubleshooting using the API Explorer available on the API documentation page, which allows to make calls without worrying about the correctness of .NET code:

Thanks, Ilya

Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.