0

I am using Angular v1.2.15 to GET a URL to retrieve JSON results.

I need to send a custom AUTHENTICATION Header with the request. the url will send back Json.

So far I can only get both $resource and $http to even send the request if I use JSONP type of request. However when I do this it does not send my CUSTOM HEADER. Can I retrieve JSON content using a normal GET request?

matthewbaskey
  • 1,027
  • 2
  • 17
  • 40
  • Yes you can. But you will probably need to enable CORS on your server. Look it up. – ribsies Feb 12 '15 at 16:32
  • I have enabled CORS. I have read the documentation and find it too abstract. I have browsed thru heaps of posts which all use different versions. – matthewbaskey Feb 12 '15 at 16:39
  • So it sounds like a CORS issue you are having. Whats your server made out of? Maybe you can show your code for the request you are trying to send and how it's supposed to be received by the server. – ribsies Feb 12 '15 at 16:41
  • I am requesting Azure mobile service table. I have localhost enabled in CORS. Not much code to show, pretty standard $http.get(), but no error message at all. Fiddler show a jsonp request, but not a $http.get. jsonp doesn't allow me to write a custom header thou. – matthewbaskey Feb 12 '15 at 16:46
  • if you are using $http.get() and CORS is not working, you should get an error. If you aren't, then that means it is working and hitting the server. Check your server logs to see if it is recognizing anything. – ribsies Feb 12 '15 at 16:50
  • Well I have Fiddler open, when I use JSONP I can see the request. I set the $http header but jsonp doesn't use it. So request fails with 'Not authorized. With Get the request doesn't even show. I use .error(function(data, status, headers, config) { but status is 0 – matthewbaskey Feb 12 '15 at 16:51
  • Fiddler open for your front end right? You need to see how the server is reading the requests. To me it sounds like the get() is getting through but then an error on the server so it doesn't send anything back. – ribsies Feb 12 '15 at 16:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/70802/discussion-between-magister-and-ribsies). – matthewbaskey Feb 12 '15 at 16:57

1 Answers1

0

The problem was the Ripple Emulator for Cordova apps was running the proxy on a different port. The the emulator was actually not allowing the http request.

matthewbaskey
  • 1,027
  • 2
  • 17
  • 40