解析值时遇到意外字符:<路径'',行0,位置0在GA api
本文关键字:位置 api GA 路径 遇到 意外 字符 | 更新日期: 2023-09-27 18:08:50
在向GA发送请求之前,我使用以下google analytics api代码进行身份验证,但我收到错误消息
"解析值时遇到意外字符:<路径",第0行,GA>
同时执行请求GAOuthService.Data.Ga.Get()
方法
我的认证码:
var scopes = new[] { AnalyticsService.Scope.Analytics,
AnalyticsService.Scope.AnalyticsEdit,
AnalyticsService.Scope.AnalyticsManageUsers,
AnalyticsService.Scope.AnalyticsReadonly};
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, userName
, CancellationToken.None
, new FileDataStore("GoogleAnalytics.Auth.Store")).Result;
var service = new AnalyticsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "xyz",
});
使用上面的代码,下面是请求的外观。
var request = service.Data.Ga.Get("ga:8903098", "2014-01-01", "2014-01-01", "ga:sessions");
request.MaxResults = 1000;
GaData result = request.Execute();
您的身份验证似乎使用变量服务返回。除非您也使用GAOuthService进行身份验证,否则调用GAOuthService.Data.Ga.Get()
可能不起作用。
你需要记住发布所有有问题的代码