javascript - GET working with Postman, but not with Ajax? -


i'm attempting simple request server hosting account data. request requires authorization header in order function correctly. have performed request , retrieved data in postman, attempting in javascript via ajax results in "invalid http status code 405" error.

below link fiddle , screenshot of postman settings. thanks.!

$.ajax({     beforesend: function(xhrobj){             xhrobj.setrequestheader("authorization","bearer tj7ltlycpqc6drup5bkhuo7uvbyaazi40");     },     type: "get",     url: "https://api05.iq.questrade.com/v1/accounts",     success: function(e){             console.log(e)     } }); 

http://jsfiddle.net/ldjbp2j8/1/

postman settings

from chrome's js console:

failed load resource: server responded status of 405 (method not allowed)

because adding authorization header, have made request complex. requires browser make preflight options request ask permission send complex request.

the server making request responding saying options requests not allowed url.

you need modify server responds appropriately preflight cors request.


postman doesn't need make preflight request because browser trusts postman's code. doesn't know if can trust code received jsfiddle (aka potential evil hacker site) data api05.iq.questrade.com (aka potential online banking or company intranet site) willing share it.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -