1

When i try to make a service call to extract data from the google spreadsheet, JSON gives me a null response? any ideas why?

Main Activity

private static final String url = https://docs.google.com/spreadsheets/d/1jEN1mzN9modYCdNKziBjaPZDl2L3lmnX2rVA1GVVPB8/gviz/tq?tq=select+*&usp=drive_web&pli=1#gid=0";

ServiceHandler serviceHandler = new ServiceHandler();
// Making a request to url and getting response
String jsonStr =  serviceHandler.makeServiceCall(url,ServiceHandler.GET,null);
Log.d("Response: ", "> " + jsonStr);

Manifest permissions

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Log cat out put

libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname) Response:(5829): > null

  • Post the URL here? Also does your Manifest have all the required permissions? – Skynet May 11 '15 at 07:42
  • URL-https://docs.google.com/spreadsheets/d/1jEN1mzN9modYCdNKziBjaPZDl2L3lmnX2rVA1GVVPB8/gviz/tq?tq=select+*&usp=drive_web&pli=1#gid=0 – Akanksha Sawarkar May 11 '15 at 08:20
  • this may help u ... http://stackoverflow.com/questions/19951466/java-net-unknownhostexception-unable-to-resolve-host-url-no-address-associ – Angad Tiwari May 11 '15 at 08:26
  • @AkankshaSawarkar I think the problem is that file has private accces only to that file. You need to change pemissions to that file(public -all on web has access) Or you can use dropbox(also file with public access, I've done same previously so it works 100%) – Andrew V. May 11 '15 at 08:26
  • I had given public access to it. Requirement is to access data from google spreadsheet and show it into the app, i can't use drop box now. Any other solution do you suggest? – Akanksha Sawarkar May 11 '15 at 08:49

1 Answers1

0

@Andrew V. ...i think this may not the problem...the above url is hitting on the browser and the result came

Working Snapshot

the below is the response json

{"version":"0.6","reqId":"0","status":"ok","sig":"1945351512","table":{"cols":[{"id":"A","label":"Sr No","type":"number","pattern":"General"},{"id":"B","label":"Customer Id","type":"number","pattern":"General"},{"id":"C","label":"Business Name","type":"string"},{"id":"D","label":"Logo Image Link","type":"string"},{"id":"E","label":"Address","type":"string"},{"id":"F","label":"Phone No","type":"number","pattern":"General"},{"id":"G","label":"Email","type":"string"},{"id":"H","label":"Browser Url","type":"string"},{"id":"I","label":"PhotoShoot Link","type":"string"},{"id":"J","label":"Offers","type":"string"}],"rows":[{"c":[{"v":1.0,"f":"1"},{"v":1.0,"f":"1"},{"v":"Dr. Bipin Deshpande"},{"v":"-"},{"v":"Chaitanya Clinic, Lane No 8, Dahanukar Colony, Kothrud, Pune"},{"v":2.025390409E9,"f":"2025390409"},{"v":"drbipin62@gmail.com"},{"v":"http://www.drbipindeshpande.com/"},{"v":"https://www.google.com/maps/@18.495701,73.811325,3a,75y,331.11h,81.46t/data=!3m5!1e1!3m3!1soIQo9XrXtKEAAAAGOwGu_Q!2e0!3e2?hl=en-GB"},{"v":"Coming soon..."}]}]}}

@Akansha ... try to log the service call and check url .. i think there is problem with your url ...

Angad Tiwari
  • 1,738
  • 1
  • 12
  • 23
  • It's showing proper JSON response on browser, but not getting valid JSON response when called through android app. Can you please suggest me How to convert Url responce into valid JSON. – Akanksha Sawarkar May 11 '15 at 17:00
  • @AkankshaSawarkar first try to log the url that is hitting from the app...and check whether the url is correct or not...i think there is problem in url...the response is the last step..you are getting the error on the first step i.e. on calling service (sending request to url) – Angad Tiwari May 12 '15 at 05:24