400使用Google c#API的错误请求
我在运行c#google api时收到一个400错误请求。我知道这最终是因为API构建了一个querystring,而查询字符串的长度太长了。如何强制API发布而不是获取 我的代码:400使用Google c#API的错误请求,c#,google-analytics,google-api,http-status-code-400,C#,Google Analytics,Google Api,Http Status Code 400,我在运行c#google api时收到一个400错误请求。我知道这最终是因为API构建了一个querystring,而查询字符串的长度太长了。如何强制API发布而不是获取 我的代码: string username = "SAMPLE@SAMPLE.COM"; string pass = "PASS"; string gkey = "?key=XXXXXXXXXXXXXXXXXXXXXXXXXXX"; string dataFee
string username = "SAMPLE@SAMPLE.COM";
string pass = "PASS";
string gkey = "?key=XXXXXXXXXXXXXXXXXXXXXXXXXXX";
string dataFeedUrl = "https://www.google.com/analytics/feeds/data" + gkey;
string accountFeedUrl = "https://www.googleapis.com/analytics/v2.4/management/accounts" + gkey;
AnalyticsService service = new AnalyticsService("API Sample");
service.setUserCredentials(username, pass);
DataQuery query1 = new DataQuery(dataFeedUrl);
query1.Ids = "ga:34197921";
query1.Dimensions = "ga:medium,ga:campaign,ga:date,ga:isMobile,ga:isTablet,ga:searchKeyword,ga:hostname";
query1.Metrics = "ga:visits,ga:visitors,ga:visitBounceRate,ga:goalStartsAll,ga:goalCompletionsAll,ga:goal1Starts,ga:goal1Completions,ga:goal2Starts,ga:goal2Completions,ga:goal3Starts,ga:goal3Completions,ga:goal4Starts,ga:goal4Completions,ga:adCost,ga:totalValue";
query1.Sort = "ga:date,ga:hour";
query1.NumberToRetrieve = 50;
query1.GAStartDate = new DateTime(2012, 1, 2).ToString("yyyy-MM-dd");
query1.GAEndDate = DateTime.Now.ToString("yyyy-MM-dd");
query1.StartIndex = 1;
我的例外情况:
Google.GData.Client.GDataRequestException:请求执行失败:https://www.google.com/analytics/feeds/data?key=XXXXXXXX&start-索引=1,最大结果=10000,维度=ga:medium,ga:campaign,ga:date,ga:isMobile,ga:isTablet,ga:searchKeyword,ga:hostname和end date=2013-11-15&ids=ga:34892951&metrics=ga:visions,ga:visitors,ga:visitBounceRate,ga:goalStartsAll,ga:goalCompletionsAll,ga:goal1Starts,ga:goal2Starts,ga:goal2Completions,ga:goal3Starts,ga:goal3Completions,ga:goal4Starts,ga:goal4Completions,ga:adCost,ga:totalValue&start date=2012-01-02->System.Net.WebException:远程服务器返回错误:(400)错误请求。位于Google.GData.Client.GDataRequest.Execute()的System.Net.HttpWebRequest.GetResponse()——内部异常堆栈跟踪的结尾——位于Google.GData.Client.GDataRequest.Execute()的Google.GData.Client.gdataAuthRequest.Execute()的Google.GData.Client.gdataAuthRequestGoogle.GData.Client.Service.Query(Uri queryUri,DateTime ifModifiedSince,String etag,Int64&contentLength)中的Google.GData.Client.Service.Query(Uri queryUri,DateTime ifModifiedSince,DateTime ifModifiedSince)中的Google.GData.Analytics.AnalyticsService.Query(DataQuery FeedQuery)中的DateQuery
核心报告API没有可用的POST。但是这不是问题所在,您还有一些其他问题
Pete,我一直在研究如何将上面的代码转换为google v3 api。我正在努力寻找如何实现这一点。以下是我的问题。1)我在哪里下载v3库。2) 您知道我在哪里可以找到一个代码示例,其中有人试图实现与我最初通过v3发布的查询类似的查询。谢谢