• da2na
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

The AJAX Proxy remoteFunction fails when posting multipart/form-data. This may be related to a previousily reported bug: Bug #192181

 

Here is the remoteFunction code:

function uploadTest(){

var content = '--7777777';
content += '\r\nContent-Disposition: form-data; name="file"; filename="test.txt"';
content += '\r\nContent-Type: text/plain';
content += '\r\n\r\n Test Test Test';
content += '\r\n--7777777--';

sforce.connection.remoteFunction({
url: 'http://test.com',
requestHeaders:{
"Content-Type": "multipart/form-data; boundary=7777777"
},
requestData: content,
method: "POST",
onSuccess : function(response) {
alert("Success: " + response);
},
onFailure : function(response) {
alert("Failure: " + response);
}
});
}

 

And, here is the response:

<html>
<head><title>400 Unable to forward request due to: Read timed out</title></head>
<body>
<h1>400 Unable to forward request due to: Read timed out</h1>
<p /><hr />
<small>

</small>
</body></html>

 

When the remoteFunction method is changed to GET, the request is successfully sent to the host without the requestData.  A possible solution may be to allow the sending of requestData with a GET method or allowing multipart/form-data to be set as the Content-Type in requestHeaders.

 

Note: Sending the same request with an Apex HttpRequest works perfectly.  However, the 100kb size limit makes it a non-viable solution.

 

Any assistance in getting the remoteFunction to work properly would be greatly appreciated!

 

-Thanks

 

 

 

 

  • April 01, 2009
  • Like
  • 0

The AJAX Proxy remoteFunction fails when posting multipart/form-data. This may be related to a previousily reported bug: Bug #192181

 

Here is the remoteFunction code:

function uploadTest(){

var content = '--7777777';
content += '\r\nContent-Disposition: form-data; name="file"; filename="test.txt"';
content += '\r\nContent-Type: text/plain';
content += '\r\n\r\n Test Test Test';
content += '\r\n--7777777--';

sforce.connection.remoteFunction({
url: 'http://test.com',
requestHeaders:{
"Content-Type": "multipart/form-data; boundary=7777777"
},
requestData: content,
method: "POST",
onSuccess : function(response) {
alert("Success: " + response);
},
onFailure : function(response) {
alert("Failure: " + response);
}
});
}

 

And, here is the response:

<html>
<head><title>400 Unable to forward request due to: Read timed out</title></head>
<body>
<h1>400 Unable to forward request due to: Read timed out</h1>
<p /><hr />
<small>

</small>
</body></html>

 

When the remoteFunction method is changed to GET, the request is successfully sent to the host without the requestData.  A possible solution may be to allow the sending of requestData with a GET method or allowing multipart/form-data to be set as the Content-Type in requestHeaders.

 

Note: Sending the same request with an Apex HttpRequest works perfectly.  However, the 100kb size limit makes it a non-viable solution.

 

Any assistance in getting the remoteFunction to work properly would be greatly appreciated!

 

-Thanks

 

 

 

 

  • April 01, 2009
  • Like
  • 0
I have an s-control that uses the AJAX proxy remoteFunction to connect to an external URL.  It has been working correctly for several months.  Over night the remoteFunction stopped working and only returns a read timeout error.
 
"400 Unable to forward request due to: Read timed out"
 
 I have eliminated and/or tested all of the other factors: connection to external site, browser, data error, IP address whitelists, etc.  I have tried using version 11 and 12 of the API.  I have also contacted the Sales Force support line with no avail.  I know that this can occur when Sales Force slows down, but it has never happened for this long 12+ hours.
 
I am left to assume that some issue with Sales Force occurred over night.  Any Ideas?
 
Code:
function postRequest(envelope) {

 sforce.connection.remoteFunction({
  url : "https://<deleted>",
  requestHeaders: {
   "Content-Type":"application/x-www-form-urlencoded; charset=utf-8"
  },
  requestData: envelope,
  method: "POST",
  onSuccess : postSuccess,
  onFailure : postFailure
 });

}