[Solved] JSONP response with angular http


We tried to call the rest api with JSON as well as JSONP method but every time we tried to get the response with JSON method we get Accept header error and then we tired JSONP method which again gives ‘Unexpected  Token : ‘ error while parsing the response. Please point us to the direction where we are doing it wrong. Thank you.

Here is our controller code of angular 

url : ‘https://restapi.surveygizmo.com/v4/survey/1529356/surveystatistic?user:pass=chris@xxxx.com:xxxxxxx&callback=JSON_CALLBACK’,
method: ‘JSONP’,
}).success(function(data, status) {
}).error(function(data, status) {


And here is our response

Uncaught SyntaxError: Unexpected token :

Richard Goodchild264162 asked

    Best answer


    Hi Richard, 

    For the API to return json or jsonp, specify the return format as follows…





    joshwa answered
      • other return options include…

      • MIND = BLOWN. This should be added to the API docs.
        (for completeness, you can specify the callback function name by adding a “callback” parameter)
        Though, if you were to use this client-side (which is the point of JSONP), your credentials (whether plaintext or md5) are still out there in the open… so in the end this is still pointless, no?



      Question stats

      • Active
      • Views13550 times
      • Answers1 answer
      • Followers0 followers