0

I have been trying for hour every possible method on this forum but no luck. PLEASSE help I have the following server url

String url = "http://namara.io/api/v0/resources/fef59c15-852f-4f4b-aaef-c9475b3d17c6/data?where=%7b%22column%22:3,%22selector%22:%22eq%22,%22value%22:%22Sercan%22%7d"

Here is my code:

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
HttpResponse response;
try {
response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
.
.
.

However i am always getting null values. When I check the StatusLineReturned code, it is saying error 401: Uauthorized.

I have no idea what is it that I am doing wrong? Why it won't just work!

Snake
  • 14,228
  • 27
  • 117
  • 250
  • 1
    even if you'll try to open it in browser, it says the same. so you need to authorize at first – nikis Mar 01 '14 at 09:05
  • 1
    look here http://namara.io/, you have to provide api_key – nikis Mar 01 '14 at 09:07
  • firstly hit your URL on browser. This URL give you unauthorized on browser. Then it will always give you unauthorized on mobile phone. – Yogendra Mar 01 '14 at 09:58
  • @nikis, OMG I cant believe it. You nailed it right. 5 hours wasted. I was trying it with my browser and it was working. when you said so, I tried another computer and didnt work. Turned out I was signed in to my account by my browser and no key was needed. Wow what a waste! Thank YOU. post it as an answer and i will accept it – Snake Mar 01 '14 at 16:27

2 Answers2

1

Posting an answer from comments:

If you'll try to open it in browser, it says the same, so you need to authorize at first. Per docs at namara.io, you have to provide api_key.

nikis
  • 11,166
  • 2
  • 35
  • 45
0

just out of curriousity : can u try

URL u = new URL(youurl);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);

if it doesnt work , maybe you need to use a post not get method

TheChix
  • 107
  • 1
  • 10