Closed bruceyue closed 9 years ago
How are you creating tkClient
? Can you post that code. Also, what do you see in the JavaScript Console?
I do it like this
var tkClient = new forcetk.Client();
tkClient.setSessionToken('{!$Api.Session_ID}');
When I call GET method, it can success.
I think there is a bug for this in forcetk apexrest method. How should I pass the paramMap params?
for (paramName in paramMap) {
xhr.setRequestHeader(paramName, paramMap[paramName]);
}
. This is the error form console
I think I see what it is - the first argument to apexrest
should be the path relative to /services/apexrest, and your JSON should be the payload, so you should call it like:
var url = '/namespace/DownloadService/';
tkClient.apexrest(
url,
function(response){
console.log(Base64.decode(response));
var responseJson = Base64.decode(response);
},
function(error){
console.log(error);
},
"POST",
'{"jsonData":"eyJvYW1lAwMDAwWVNJbUFBTyJ9"}'
);
paramMap
is if you want to pass extra HTTP headers. You don't need to set it or the retry flag
Yes, it works for fetching small data, but for large data, this error occurred. How to ffix it.
OK - the problem here is that Apex REST calls still have to go through the Ajax Proxy (unlike the Force.com REST API, Apex REST is not exposed on the Visualforce hostnames - the Winter '16 release might fix this #safeharbor). The Ajax Proxy has a fixed 10 second timeout, so long running operations will fail.
Right now, the only way to do this is to deploy your own proxy with CORS support, or figure out a way to use the REST API.
@metadaddy is there a way to fork forcetk and change the 10 second timeout? can you throw a file that I should start looking to change that?
@leordev If you're using the Ajax proxy, you're stuck with the 10 second timeout - that's in the proxy service itself at Salesforce. You may not need to even use the proxy, though. Try disabling it and see if it works - see http://salesforce.stackexchange.com/a/13171/67
@metadaddy oh I see it... it's on the server side, not on the client. yeah, the problem is that I'm not using the APEX Rest Data service. I'm using only custom APIs that I created in the environment! Thank you!
returned this 'net::ERR_CONNECTION_RESET'
Here is my code: