• almazanjl
  • NEWBIE
  • 50 Points
  • Member since 2012

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

I'm attempting to integrate the jQuery File Uploader utility built by blueimp into a visualforce page that will be embedded into a custom object's page layout. I have the front-end done but now I'm a little stuck for getting the back-end working. I was going to have the form submit to an Apex REST Method, but the content-type multipart/form-data isn't supported. I've seen some workarounds on the web for uploading to external servers but I'm still having trouble getting the light bulb to go off for my use case; any help is greatly appreciated, thanks!

Dear Geeks,

 

I am using Force.com IDE - Version: Summer '12 (25.0.0) and Eclipse IDE for Java Developers - Version: Helios Service Release 2 Build id: 20110301-1815.

 

I have created a Force.com project in Eclipse to retrieve all the fields from Standard Object called Campaign. While exploring the salesforce schema, I can see only 31 standard fields of Campaign standard object whereas, in free Developer Edition of salesforce.com, there are 37 standard fields in Campaign Object.

 

What are the Eclipse configuration changes required to see all the standard fields of Campaign Object listed in salesforce Developer Edition?

 

Thanks,

  • September 13, 2012
  • Like
  • 0
Hi everyone.

I am trying to sign an XML with the APEX method Crypto.signXml(), but I am not able to obtain a valid signature.

I'm developing in Salesforce an integration with an external SOAP Web Service that expects an XML document signed with a certain certificate (Test_Certificate) installed in the Salesforce organization.

Here is my APEX example:
 
String xml = '<request><request_meta><service>Test 1</service></request_meta></request>';

Dom.Document doc = new dom.Document();
doc.load(xml);

System.Crypto.signXml('RSA-SHA1', doc.getRootElement(), null, 'Test_Certificate');
System.Debug('********** Document signed: ' + doc.toXmlString());
But when I check the validity of the signature (value of doc.toXmlString ()), with an external tool like this: https://www.aleksey.com/xmlsec/xmldsig-verifier.html the result is always the same:

Error: signature verification failed

Here is the return value of the signed document:
 
<?xml version="1.0" encoding="UTF-8"?><request ID="_6087196b72facc986593cf1805d5055f5e5bd52e"><request_meta><service>Test 1</service></request_meta><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><ds:Reference URI="#_6087196b72facc986593cf1805d5055f5e5bd52e"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><ds:DigestValue>cqoiEh1rYlvizSfk5wvTQMUoKu8=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>KQqNHBuVf94Lo9cl3xTqYfMyazkqrPtdkV5FzgTBiQwN43wdlwfgU5eC7GErAoeuGTAFPRoJB5Oa
wjQbd+03I7KCY3R5IYZbdpgQojGBL1KiEWxno1H2+KQ1Cl55UPGXAhfKW8YsJYeFG/v8j2x9ppxS
jliaQCojWVX/wHkDqr2IHzB3Lh/qbHLCnzOkCMH42LX/6hChR8fViF4XXFiQjMUWgsBntTdtnk4l
82Cjuj098HeeyjMJEZyzYBL3hYIeUo/DKdi904mHrAEtpfcdQdk7KcYYI4Fp//XgAyDufECJ5PJv
RpJb+YZ37rQFKZjGMN6GFSMgLPPpoqON2+Kirg==</ds:SignatureValue><ds:KeyInfo><ds:KeyValue><ds:RSAKeyValue><ds:Modulus>tkMikn1uOvHPnMl3OHfylzKZ97NNoLwpYdlaed8zxuF/XZZgsxOGKwoI08Pp8Kf174ziyyPtGvUQ
X9TTy03EDt2BRt6r7B3fO9oN6dXv9E7bH/60eo56oJt7QDtd5epSqxBRCa+5HxeQlYeS6XrmuTmK
GGne/ZCJ23uYGKWXvy9MB7yBBZb4AeseKg7ku2rEoEOt/+3TNNQdO4pPZkwRXmAfV3G3dUltznvl
4lATBNAiHW2N2dJGIMt0+dV6pefdzwsYrPwMquYQsL7lKZ5paq3EwMRaeXGuKkGoEo0wUcHazJUo
Wgmbhn+PzBvqGZrsV3zTfEjlqmP0cY3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DEVMBMGA1UECgwMVGlj
TWluZF8yMDQ4MRUwEwYDVQQLDAxUaWNNaW5kXzIwNDgxFTATBgNVBAMMDFRpY01pbmRfMjA0OIIJ
APy1RVtialntMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBADehkBaDiviyrfSveTW1
bk36YQBrKbUQ7aXrvawVtLH4oXHWF2mkZDyAqCk5OBr70VVkP9tS7gx/peafgqw8kpE8cFOk+eIu
KXCUKw7NM3L1AneyoLTo8XwFfieOjHp03C330+e0jvkh/KUASfaS4sc6IQKnxxfbTcPNB/jA1mk1
Woaf49UlQ3koJ59ZThO3IerdD/3Shzv1MifKKIIjUohW+EdTGnM+FLsGSWKd+c+0fE1qDn9JI1zM
twGqRC+rcsg6WOZ1YM487Rqc/4HJf+NJErkJDEFBC01BRlEVoo/NPj0Dl7lpxwcQRBUhGXVJe4ym
9M2e3jdIdsJtLwc7WjM=</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature></request>
I've tried everything already, but I never get a valid signature.

Any suggestion is welcome.

Thanks in advance.
 

Hi all.

 

As noted in this post that talks about notifications in Salesforce1, is there any document about the universal notification framework? I find nothing concerning “send push notifications to individuals and groups using Apex”.

 

Thanks.

 

 

Hi,

 

We've tryed the <chatter:feed> component inside a custom apex page and we are having issues with the "rerender" method, the first time that the object is rendered it shows all the feeds but when we try to call to the method <apex:actionFunction> passing the id of the chatterfeed object to the rerender parameter it doesn't retrieve all the feeds from a group.

 

Here is the code:

 

Visualforce page:

 

<apex:page controller="Elogos_ChatterController" sidebar="false" showheader="false">
      <a href="#" onclick="UpdateChatterFeed('xxxx');">Test Chatter Group</a>
      <apex:form >
            <apex:actionFunction name="UpdateChatterFeed" action="{!DoSomething}" rerender="chatterFeed" >
                  <apex:param name="entityId" assignTo="{!EntityId}" value="" />
            </apex:actionFunction>
      </apex:form>
      <chatter:feed id="chatterFeed" feedItemType="TextPost" showPublisher="true" rendered="true" entityId="{!EntityId}"/>
</apex:page>

 

Controller:

 

public with sharing class Elogos_ChatterController {

	public String EntityId{get;set;}
	
	public Elogos_ChatterController (){
		this.EntityId = 'xxxx'; // Chatter Group Id
	}
	
	public PageReference DoSomething(){
		return (null);	
	}
}

 

I hope your help.

 

Regards.

 

José Luis Almazán.

I have the contents of a PDF in base64 format, Which returns a Web service, but I do notknow how to render the content on a page of VF.

 

Does anyone have any ideas how I can do? I find no solution.

 

Thanks in advance.

Hi all.

 

As noted in this post that talks about notifications in Salesforce1, is there any document about the universal notification framework? I find nothing concerning “send push notifications to individuals and groups using Apex”.

 

Thanks.

 

 

I'm attempting to integrate the jQuery File Uploader utility built by blueimp into a visualforce page that will be embedded into a custom object's page layout. I have the front-end done but now I'm a little stuck for getting the back-end working. I was going to have the form submit to an Apex REST Method, but the content-type multipart/form-data isn't supported. I've seen some workarounds on the web for uploading to external servers but I'm still having trouble getting the light bulb to go off for my use case; any help is greatly appreciated, thanks!

Hi,

 

We've tryed the <chatter:feed> component inside a custom apex page and we are having issues with the "rerender" method, the first time that the object is rendered it shows all the feeds but when we try to call to the method <apex:actionFunction> passing the id of the chatterfeed object to the rerender parameter it doesn't retrieve all the feeds from a group.

 

Here is the code:

 

Visualforce page:

 

<apex:page controller="Elogos_ChatterController" sidebar="false" showheader="false">
      <a href="#" onclick="UpdateChatterFeed('xxxx');">Test Chatter Group</a>
      <apex:form >
            <apex:actionFunction name="UpdateChatterFeed" action="{!DoSomething}" rerender="chatterFeed" >
                  <apex:param name="entityId" assignTo="{!EntityId}" value="" />
            </apex:actionFunction>
      </apex:form>
      <chatter:feed id="chatterFeed" feedItemType="TextPost" showPublisher="true" rendered="true" entityId="{!EntityId}"/>
</apex:page>

 

Controller:

 

public with sharing class Elogos_ChatterController {

	public String EntityId{get;set;}
	
	public Elogos_ChatterController (){
		this.EntityId = 'xxxx'; // Chatter Group Id
	}
	
	public PageReference DoSomething(){
		return (null);	
	}
}

 

I hope your help.

 

Regards.

 

José Luis Almazán.

Dear Geeks,

 

I am using Force.com IDE - Version: Summer '12 (25.0.0) and Eclipse IDE for Java Developers - Version: Helios Service Release 2 Build id: 20110301-1815.

 

I have created a Force.com project in Eclipse to retrieve all the fields from Standard Object called Campaign. While exploring the salesforce schema, I can see only 31 standard fields of Campaign standard object whereas, in free Developer Edition of salesforce.com, there are 37 standard fields in Campaign Object.

 

What are the Eclipse configuration changes required to see all the standard fields of Campaign Object listed in salesforce Developer Edition?

 

Thanks,

  • September 13, 2012
  • Like
  • 0

Hi,

 

I need to send an image to an external service through apex api call.

 

1)does salesforce support multipart/form-data in api call ??

 

2) also i need to send parameter (name of image) to that external service .so can i send blob as value string parameters in a single request ??

 

Thanks for your suggestions

 

I'm trying to send a file that's attached to a Case out of my APEX Code, I'm trying to 'form' the POST request and pass the attachments body in the post request as follows:

 

HttpRequest req = new HttpRequest();
req.setHeader('Authorization','Basic '+EncodingUtil.base64Encode(Blob.valueOf('----:0000')));
req.setHeader('Content-Type','multipart/form-data; boundary=-----------------------------153501500631101');
req.setHeader('Content-Length',String.valueOf(attachments[0].BodyLength));
req.setMethod('POST');  
req.setEndpoint(endPoint+'/createattachment');
		
String body = '-----------------------------153501500631101\r\n';
body = body + 'Content-Disposition: form-data; name="Filedata"; filename="'+attachments[0].Name+'"\r\n';
body = body + 'Content-Type: '+attachments[0].ContentType+'\r\n\r\n';
body = body + attachments[0].Body + '\r\n';
body = body + '-----------------------------153501500631101--\r\n';
    req.setbody(body);
try{
  Http http = new Http();
  HTTPResponse res = Http.send(req);
}

 Everything looks good in the debugger (which reports the body as being 'Blob', even though it's a string ?) 

 

And the server sends back a 200, but the attachment doesn't appear?

 

I've added this question to stackoverflow.com: http://stackoverflow.com/questions/10215808/post-multipart-form-data-out-of-salesforce-com-apex

I have the contents of a PDF in base64 format, Which returns a Web service, but I do notknow how to render the content on a page of VF.

 

Does anyone have any ideas how I can do? I find no solution.

 

Thanks in advance.

Hi

 

I'm trying to upload Files from Visualforce page and APEX, via HttpRequest like this:

 

        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint(ENDPOINT_URL);
    	req.setBody('file='+EncodingUtil.urlEncode(att.Name, 'UTF-8').replace('+','%20'));
	req.setHeader('Content-Type','application/x-www-form-urlencoded');
		
        OAuth oa = new OAuth();
        oa.sign(req);
        
        /* random string */
        String boundary = 'R50hrfBj5JYyfR3vF3wR96GPCC9Fd2q2pVMERvEaOE3D8LZTgLLbRpNwXek3';
	req.setHeader('Content-Type','multipart/form-data; boundary='+boundary);
		
        String bd='--'+ boundary +'\r\n';
        bd+='Content-Disposition: form-data; name=file; filename='+ att.Name + '\r\n';
        bd+='Content-type: application/octet-stream\r\n';
        bd+='\r\n';
        bd+= att.Body.toString();
        bd+='\r\n';
        bd+='--'+ boundary +'--';
        req.setBody(bd);
        HttpResponse res = null;
       	res = h.send(req);

 

VF page code is:
<span class="normal" style="font-weight:bold;">Select file:&nbsp;
<apex:inputfile styleClass="normal" id="file" size="25" value="{!att.Body}" fileName="{!att.Name}" />
</span>

 <apex:commandButton value=" Upload " action="{!UploadFile}" />

 

This code is working fine for text files, but when I upload an Image or pdf file the upload gets corrupted. Can anyone tell mw what's wrong with this code? plz ...

 

 

  • January 25, 2011
  • Like
  • 0

 

Hi All
 
I m quite new in salesforce Integartion.
I m working on  a Integrating salesforce to watchdox
Watchdox is actually meant for protecting Documents
 
I have the API which I need to used and also I have succeded in esatablishing a connection between watch dox and salesforce using LOGIN
 
Next I need to uplaod the document to the watchdox
 
I m pasting here the my code
 

 

Hi All 

I m quite new in salesforce Integartion.

I m working on  a Integrating salesforce to watchdox

Watchdox is actually meant for protecting Documents 

I have the API which I need to used and also I have succeded in esatablishing a connection between watch dox and salesforce using LOGIN

 Next I need to uplaod the document to the watchdox

 I m pasting here the my code 

 

 

 

Hi All

 

I m quite new in salesforce Integartion.

I m working on  a Integrating salesforce to watchdox

Watchdox is actually meant for protecting Documents

 

I have the API which I need to used and also I have succeded in esatablishing a connection between watch dox and salesforce using LOGIN

 

Next I need to uplaod the document to the watchdox

 

I m pasting here the my code

 

 

public static void getWatchDocs() 

    {

 

 

 

       // String url= 'https://api.watchdox.com/login?User name='+UserName+'&Password='+Password;

        String url= 'https://api.watchdox.com/session';

        Http h = new Http();

       // Instantiate a new HTTP request, specify the method (Post) as well as the endpoint

        HttpRequest req = new HttpRequest();

 

        req.setEndpoint(url + '/' + UserName);

        System.debug(url + '/'+ UserName);

        req.setMethod('POST');

 

       req.setHeader('Content-Type', 'application/json; charset=UTF-8');

       req.setHeader('x-wdox-version', '1.0');

 

       req.setBody(' { \"password\" : \"' + Password + '\" } ');   

       System.debug('request is........' + req.getBody());

       System.debug('request header is........' + req.getHeader('x-wdox-version'));

 

        HttpResponse res;        

        String resURL;

        res = h.send(req);

        String Data = res.getHeader('x-wdox-ssid');

        System.debug('reponse is........' + res);

        System.debug('reponse is........' + res.getBody());

        System.debug('reponse header is........' + res.getHeaderKeys() + '.....'+res.getHeader('x-wdox-ssid'));

        System.debug(data);

        sessid=res.getHeader('x-wdox-ssid');

        getguid();

        //getdocs(res.getHeader('x-wdox-ssid'));

    } 

    public static void getguid()

    {

       String url1= 'https://api.watchdox.com/document';

        Http h1 = new Http();

       // Instantiate a new HTTP request, specify the method (Post) as well as the endpoint

        HttpRequest req1 = new HttpRequest();

 

        req1.setEndpoint(url1);

        System.debug(url1);

        req1.setMethod('GET');

       //req.setHeader('Content-Type', 'application/json; charset=UTF-8');

       req1.setHeader('x-wdox-version', '1.0');

       req1.setHeader('x-wdox-ssid', sessid);//'aB9Ctg5U1t3Z6DYLmk2ShLNFrz4wrnRBBS4unt4deKswTQgOIuwe5DWCpUEu/VWU7d6vBq4.kntvAC02gwc.4ZSCZfkAZs4g5VLiNX1LaU/0');

       System.debug('request header is........' + req1.getHeader('x-wdox-version')); 

       System.debug('request header is........' + req1.getHeader('x-wdox-ssid')); 

 

       HttpResponse res1;        

       String resURL1;

       res1 = h1.send(req1);

       guid=res1.getBody(); 

 

       System.debug(guid);

       uploaddocs();

}

 

public static void uploaddocs()

 

{    

        String subguid=guid.substring(9,45);

        System.debug(subguid);

        String FileName = 'sample.doc.docx';

        //Blob bodyContent=blob.valueof('FileName');

        //system.debug( bodyContent );

        String url2= 'https://api.watchdox.com/document';

 

        Http h2 = new Http();

        HttpRequest req2 = new HttpRequest();

        req2.setEndpoint(url2 + '/' + subguid + '/upload');

        System.debug(url2);

        req2.setMethod('POST');

        req2.setHeader('Content-Type', 'multipart/form-data');

        req2.setHeader('x-wdox-version', '1.0');

        req2.setHeader('x-wdox-ssid', sessid);

 

        // req2.setBody('{ filename= ' + NewDocument + ' ,Data= BYTE[] }'); 

 

        System.debug('request is........' + req2.getBody()); 

        HttpResponse res2;        

        String resURL2;

        res2 = h2.send(req2); 

 

}

 

}

 

 

 

But in this code in upload docs method I m having errors .

 

When I contacted the watchdox support they provided me the following information which is required to be added

 

The following link http://code.activestate.com/recipes/146306-http-client-to-post-using-multipartform-data/ has an example written in python how a mutlipart request can be manually constructed.

 

For example, suppose I wanted to send the file name "hello.bin" who's content was 10 lines containing the number 12345.

In the header, 

set x-wdox-version to         1.0

set x-wdox-ssid to the ssid you get from the login procedure

set content-type to              multipart/form-data; boundary=----------ThIs_Is_

tHe_bouNdaRY_$

 

The body of the post should be 

 

------------ThIs_Is_tHe_bouNdaRY_$

Content-Disposition: form-data; name="data"; filename="hello.bin"

Content-Type: application/octet-stream

 

12345

12345

12345

12345

12345

12345

12345

12345

12345

12345

 

------------ThIs_Is_tHe_bouNdaRY_$--

Since I m quite new in using web services and not even aware of phython i want to translate this information in Apex syntax

For req.Header i have written the Apex syntax

but facing problems in using req.Body ( ) in Apex syntax for the above requirement.Actually I need to pass filename and file data in request Message Body

May be I have to use Blob here .

Can anyone help please?

 

 

 

 

Thanks 

Hi ,

      I am sending an http request to an third party server from salesforce ,here am using an httprequest  to post the data to third party server ,the data is documents to third party content management system I know the apex limitation 100kb ,am sending below 100kb am get only txt files now all other documents are corrupting I tried a lot using different any one can help me in this issue here is my code.

 

sending an http request to third party application using multipart.

 

 

 

String response; String boundary = 'AaBbCcX30'; String m_URL = 'some url'; String content = 'Content:\r\n--' + boundary + '\r\nContent-Disposition:form-data;name="' + p_fileName + '";filename="'+p_fileName+'"\r\n'; content +='Content-Type:' + p_fileContentType + ',charset=ISO-8859-1,*,utf-8\r\n'; content +='Content-Transfer-Encoding: binary\r\n\r\n'; content += p_fileBlob +'\r\n\r\n'; content += '--'+boundary+'--\r\n'; System.debug(p_fileBlob.size()+'content ' + content); Http m_http = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(m_URL); req.setHeader('Content-Type','multipart/form-data;boundary='+boundary); req.setMethod('POST'); req.setBody(content); HttpResponse m_httpResp = null; m_httpResp = m_http.send(req); m_strHttpResp = m_httpResp.getBody();

 

 

  • March 11, 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
 });

}