Wednesday, 15 September 2010

javascript - $http.jsonp requests are gettings canceled -


I swear that it was working earlier, took a break, and now it is not working again. ..

I am creating an AngelJs app that connects to a custom public restore API that I have created with Salesforce. I have tested the REST API through curl and apigee.com and the data is being returned properly. The problem occurs when I try to call the same endonance via the callers $ http.jsonp () method. According to the Chromes Network Monitor, when I try to do this, it is canceled.

Kangaroo Factory:

  angular.module ('SalesforceService', [], function ($ rendered) {$ Factor. ('$ Sales force', function ($ http, $ q) {return: function (email, password) {var endpoint = 'https: // merchant .dev1.cs15.force.com / freelance / services / apex / freelance service ? Name = Jonathan and callback = JSONClubback '; var deferred = $ q.defer (); console.log (' ... calling cellforce ... '); $ Http.jsonp (endpoint) .success (data) {Console.log ('- SALESFORCE RESPONSE:'); console.log (data); deferred.resolve (data);}) error. Ray (data, position, header, config) {console.log ('--- error error:'); console.log (data); console.log (status); console.log (header); console. Log (Config); deferred.reject ('An error occurred while attempting to login.');}); Return returned. > Then I call $ Serviceforce.l by one of my controllers in this service ogin () ...  

Custom Salesforce Comfort Class:

 < Code> @RestResource (urlMapping = '/ freelance service') global class freelance service {global class test consumption Concept {public string message; Public test object (string message) {this.message = message; }} @HttpGet global constant zero goGet () {string name = restContext.request.params.get ('name'); Test object o = new test object ('hello' + name); RestContext.response.addHeader ('Content-Type', 'App / Jason'); RestContext.response.responseBody = Format Response (O); } Public Static Blob Format Response (TestObject Obje) {// string string immediately to return the string response; Get callback parameter from // url string callback = RestContext.request.params.get ('callback'); // Return is wrapped in JSON function if a callback parameter is present (callback! = Null) {feedback = callback + '(' + JSON.serialize (obj) + ')'; } And {response = JSON.serialize (obj); } Return blob.valueOf (feedback); }}   

I do not understand why it is not working for life ... any thoughts?

exits because the Salesforce REST service was being served from the sandbox instead of production, Chrome automatically A certificate name was canceling the request due to a mismatch error.

Implementation Guide to Salesforce Sites:

Only valid for organizations to access sites using HTTPS is safe. Force are SSL certificates. Note: If a site is using HTTPS inside a sandbox (non-production) organization, then a certificate name may appear mismatched alert

No comments:

Post a Comment