2

I am trying to access information through a GET request. My javascript code is getting a successful response, but with an empty JSON array. I am trying to debug using curl and Firefox. Here is where it gets strange.

Here is a successful request through the Firefox:

 http://api.example.com/v4/layers/2178198/features?token=...&filter=time%253E1384889546

This returns a bunch of data. This also works in my javascript code.

Now I do exactly the same request with a slightly different resource:

http://api.example.com/v4/layers/2178199/features?token=...&filter=time%253E1384889546

And I get a success, but the JSON array returned is empty. I do this exact same request with curl (from the same machine):

curl  http://api.example.com/v4/layers/2178199/features?token=...&filter=time%253E1384889546

and I get a JSON array full of data.

So I know that I can GET data from the server with javascript and Firefox. And I know that this resource is valid, because I can access it through CURL. Why oh why do I get no data when accessing through the browser? I am very confused.

wx13
  • 85
  • 1
  • 1
  • 7
  • 1
    Have you tried clearing your browser cache? Is it possible you requested the /2178199 resource previously and the empty result is cached? – David Fleeman Nov 19 '13 at 20:14
  • I just cleared the cache and tried it, still with no luck. I even used a different browser that I haven't tried this on yet, and still no luck. – wx13 Nov 19 '13 at 20:24
  • 1
    What affect does your token and filter querystring params have on the request? Is it possible that the token you are passing via the browser is in conflict with session state? – David Fleeman Nov 19 '13 at 20:37
  • @DavidFleeman, you are on to something. It seems to be a combination of two problems. One is on the server end: the data that should be there is not there. The other is that I didn't quote my cURL request, so the shell was corrupting the filter string and thus returning the wrong data. – wx13 Nov 19 '13 at 20:49
  • Who is the API provider you're pulling data from? – brandonscript Dec 08 '13 at 20:35
  • possible duplicate of [how to transform from curl command to ajax request](http://stackoverflow.com/questions/13243595/how-to-transform-from-curl-command-to-ajax-request) – Paul Sweatte Mar 25 '14 at 15:48

0 Answers0