I am using google client api to integrate youtube in my android app. I am using this code,
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);
while getting the feed it throws com.google.api.client.http.HttpResponseException: 400 Bad Request. First few times it worked properly and then it is giving 400 bad request. How to overcome this problem? Plz help. Thanks in advance.
Actuall I was missing to add headers
GoogleHeaders headers = new GoogleHeaders();
headers.setApplicationName(“TestApp/1.0”);
headers.gdataVersion = “2”;
request.headers = headers;
Adding the headers to the HttpRequest solved the 400 Bad Request Exception.
Enjoy…!!!