我正在使用google client api将youtube集成到我的android应用中。我正在使用此代码,
YouTubeUrl url = new YouTubeUrl(VIDEOS_FEED);
url.author = "searchstories";
url.maxResults = 2;
// build the HTTP GET request
HttpRequest request;
try {
request = factory.buildGetRequest(url);
// execute the request and the parse video feed
VideoFeed feed = request.execute().parseAs(VideoFeed.class);
在获取Feed时会引发com.google.api.client.http.HttpResponseException:400错误的请求。最初几次它工作正常,然后给出了400个错误的请求。如何克服这个问题?请帮助。提前致谢。
最佳答案
实际上我缺少添加标题
GoogleHeaders header =新的GoogleHeaders();
headers.setApplicationName(“TestApp / 1.0”);
headers.gdataVersion =“2”;
request.headers = header ;
将 header 添加到HttpRequest中解决了400 Bad Request Exception。
请享用...!!!
关于android - 如何在Android中使用Google Client API时克服400错误请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6749882/