Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions forcetk.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,10 @@ if (forcetk.Client === undefined) {
* @param [error=null] function to which jqXHR will be passed in case of error
* @param [method="GET"] HTTP method for call
* @param [payload=null] payload for POST/PATCH etc
* @param [paramMap={}] parameters to send as header values for POST/PATCH etc
* @param [retry] specifies whether to retry on error
*/
forcetk.Client.prototype.apexrest = function(path, callback, error, method, payload, retry) {
forcetk.Client.prototype.apexrest = function(path, callback, error, method, payload, paramMap, retry) {
var that = this;
var url = this.instanceUrl + '/services/apexrest' + path;

Expand All @@ -268,7 +270,7 @@ if (forcetk.Client === undefined) {
that.refreshAccessToken(function(oauthResponse) {
that.setSessionToken(oauthResponse.access_token, null,
oauthResponse.instance_url);
that.ajax(path, callback, error, method, payload, true);
that.apexrest(path, callback, error, method, payload, paramMap, true);
},
error);
} else {
Expand All @@ -280,6 +282,13 @@ if (forcetk.Client === undefined) {
if (that.proxyUrl !== null) {
xhr.setRequestHeader('SalesforceProxy-Endpoint', url);
}
//Add any custom headers
if (paramMap === null) {
paramMap = {};
}
for (paramName in paramMap) {
xhr.setRequestHeader(paramName, paramMap[paramName]);
}
xhr.setRequestHeader(that.authzHeader, "OAuth " + that.sessionId);
xhr.setRequestHeader('X-User-Agent', 'salesforce-toolkit-rest-javascript/' + that.apiVersion);
}
Expand Down