I am working with Google Spreadsheet API in Android. I am successfully done with the integration and able to retrieve the rows. But facing a little problem in search functionality. I am having 3-4 different search for the spreadsheet. The problem is that in my spreadsheet in some columns I am having space between words.
For e.g Hello World is a value in row number 5 and the header name for this row is let say test.
So when i search for the Hello World it is throwing InValidEntryException : Bad Request.
I also try with URLEncoder.encode(String url) and also replace the space with %20. But none of that work for me. I know i am getting the error because of the space but don't know how to resolve. Tried with this 2 things but still struggling with the error.
If anyone has any idea please kindly help. Below is the error log.
Error Log :-
10-09 14:26:29.048: I/System.out(1009): URL ==> https://spreadsheets.google.com/feeds/list/tl5vghRJs8_wuVQWnk5TnhA/od6/private/full?sq=streetname=bal%20bay
10-09 14:26:30.327: D/dalvikvm(1009): GC_CONCURRENT freed 439K, 46% free 3492K/6407K, external 920K/1417K, paused 18ms+14ms
10-09 14:26:31.847: I/System.out(1009): Service
10-09 14:26:31.877: W/System.err(1009): com.google.gdata.util.InvalidEntryException: Bad Request
10-09 14:26:31.887: W/System.err(1009): Parse error: null
10-09 14:26:31.967: W/System.err(1009): at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:602)
10-09 14:26:32.217: W/System.err(1009): at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
10-09 14:26:32.228: W/System.err(1009): at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
10-09 14:26:32.228: W/System.err(1009): at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
10-09 14:26:32.228: W/System.err(1009): at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
10-09 14:26:32.228: W/System.err(1009): at com.google.gdata.client.Service.getFeed(Service.java:1135)
10-09 14:26:32.228: W/System.err(1009): at com.google.gdata.client.Service.getFeed(Service.java:998)
10-09 14:26:32.237: W/System.err(1009): at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
10-09 14:26:32.259: W/System.err(1009): at com.google.gdata.client.Service.getFeed(Service.java:1017)
10-09 14:26:32.259: W/System.err(1009): at com.test.voter.SearchActivity$SearchTask.doInBackground(SearchActivity.java:144)
10-09 14:26:32.259: W/System.err(1009): at com.test.voter.SearchActivity$SearchTask.doInBackground(SearchActivity.java:1)
10-09 14:26:32.259: W/System.err(1009): at android.os.AsyncTask$2.call(AsyncTask.java:185)
10-09 14:26:32.278: W/System.err(1009): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
10-09 14:26:32.287: W/System.err(1009): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
10-09 14:26:32.287: W/System.err(1009): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
10-09 14:26:32.312: W/System.err(1009): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
10-09 14:26:32.312: W/System.err(1009): at java.lang.Thread.run(Thread.java:1019)
EDIT
1)URL listFeedUrl = new URI(worksheet.getListFeedUrl().toString() + "?sq=" + URLEncoder.encode("streetname=\"164Th\"")).toURL();
2)URL listFeedUrl = new URI(worksheet.getListFeedUrl().toString() + "?sq=" + URLEncoder.encode("streetnumber=\"1923\"%20and%20streetname=\"164Th\"")).toURL();
(1) Works perfectly fine but when used multiple parameter (2) it does not work, giving the same InvalidEntryException again.