Created
November 11, 2014 11:59
-
-
Save swapnilshrikhande/d1e018a3ebf3d56252db to your computer and use it in GitHub Desktop.
CORS_using_SF_PROXY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var credential = ' OAuth ' + "<session id of target org >"; // native VF function | |
var apiUrl = "https://ap1.salesforce.com/services/data/v26.0/chatter/users/me"; | |
$.ajax({ | |
type: "GET", | |
// for community pages, use whole community url including path, e.g. | |
// https://logan.blitz01.t.force.com/customers/services/proxy. | |
url: "https://na9.salesforce.com/services/proxy", | |
contentType: 'application/json', | |
cache: false, | |
success : function(response) { | |
console.log("result",response); | |
}, | |
error : function(response) { | |
console.log("Failed",response); | |
}, | |
dataType: "json", | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader('SalesforceProxy-Endpoint', apiUrl); | |
xhr.setRequestHeader("Authorization", credential); | |
xhr.setRequestHeader('X-User-Agent', 'MyClient'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment