Issue while calling Rest API from Javascript RRS feed

  • Question

  • Hi All,

    I want to consume Rest API through Java script code. I have to pass username and password in service request.

    But when I am going to call Rest API, It gives me an error message related to cross domain.  When I contacted those who has developed this Rest API, they confirmed that CORS is not enabled on this API and call that Rest API from server side.

    They also mentioned that CORS is not enable on this API because it led security lapse as Username and Password can be easily taken out from JavaScript source.

    Please guide on this. Also, Is there any other way to Call this API from Java script?

    Any help will be grateful !


    Ravideep Bansal

    Wednesday, April 16, 2014 6:03 AM


  • HI 

    Create new WCF Service,  enable  Cross Origin Resource Sharing (CORS) on this so that actual WCF Rest API's can be accessed from this WCF service , refer here ,

    the newly created WCF service with CORS enabled can be easily used to access Rest ApI's from Javascript 

    On new WCF service you should take care the below points

    use encryption whereever possible, and use WSHttpBinding with transport and message security feature inplace



    Rajesh Sajjanar

    Wednesday, April 16, 2014 6:29 AM