• Itru
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 6
    Replies
I'm trying to make an HTTP Request to other System.

They provided the endpoint URL which contains a Port number.

https://Test.com:50001/RESTAP/BGN/PRDV/CREATE

When I'm trying to make the request I facing with this ERROR:

> System.CalloutException: Unable to tunnel through proxy. Proxy returns
> "HTTP/1.1 503 Service Unavailable"

although I have added the URL in remote sites.

When I make the request from Postman - I get the response as expected.

My code is : 

    Http httpProtocol = new Http();
            HttpRequest request = new HttpRequest();
            String url = 'https://Test.com:50001/RESTAP/BGN/PRDV/CREATE';
            String username2 = 'Name';
            String password2 = 'Passowrd';
            Blob headerValue = Blob.valueOf(username2 + ':' + password2);
            String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
            request.setEndpoint(url);
            request.setMethod('POST');
            request.setHeader('Authorization', authorizationHeader);
            request.setTimeout(60000);
    
    
            request.setHeader('Content-Type','application/json');
            request.setHeader('proxyPort','50001');
            request.setHeader('proxyHost','PROXYHOST URL');
            request.setHeader('proxySet','true');
    
            HttpResponse response = httpProtocol.send(request);


Note: The userName and Password will be filled from Custom setting.

I tried with and without the proxy header, I tried to turn the BASIC auth to Basic and many other little changes that didn't work.

I'm still getting this Error.

How can I know if it not blocked by Firewall? 

Any help or Idea to solve this issue

Thanks!
  • August 27, 2019
  • Like
  • 0
Hi everyone,
I would appreciate if you could help me to find out what are the limitations that SF put for outbound email messages with attachments size.
Currently, I'm using the SingleEmailMessage method using Apex, to add all the attachments in a single case, and send it to a contact email.
I little confused, I saw a lot of documentation that talked about 10MB for all the attachments inside the same email and 3 -5 MB for a single attachment - beyond that - It converts all the attachments into .html links on an open and insecure servlet.
I tried it out with the "trial and error" method with different attachments size.
I took some attachments that their sum was 16MB together and succeeded to see the email attachment (not the link - the real attachment) in my Gmail account.
But on 18MB it failed and supplied to me only the link to the servlet.
With one attachment I succeeded to see if it was 7MB but beyond it - it just sent me those links again.
The weird thing is that in another case I could see a single file of 15MB!  (Same Email Template).

Can someone here please help me to understand it?
What is the size that SF can commit to, on outbound email attachments - before it converts them to .html links?
If it does convert it to .html links - what is the limitation now?
Hope I was clear enough and thanks in advance,
Itai.





 
  • October 21, 2018
  • Like
  • 0
I'm trying to make an HTTP Request to other System.

They provided the endpoint URL which contains a Port number.

https://Test.com:50001/RESTAP/BGN/PRDV/CREATE

When I'm trying to make the request I facing with this ERROR:

> System.CalloutException: Unable to tunnel through proxy. Proxy returns
> "HTTP/1.1 503 Service Unavailable"

although I have added the URL in remote sites.

When I make the request from Postman - I get the response as expected.

My code is : 

    Http httpProtocol = new Http();
            HttpRequest request = new HttpRequest();
            String url = 'https://Test.com:50001/RESTAP/BGN/PRDV/CREATE';
            String username2 = 'Name';
            String password2 = 'Passowrd';
            Blob headerValue = Blob.valueOf(username2 + ':' + password2);
            String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
            request.setEndpoint(url);
            request.setMethod('POST');
            request.setHeader('Authorization', authorizationHeader);
            request.setTimeout(60000);
    
    
            request.setHeader('Content-Type','application/json');
            request.setHeader('proxyPort','50001');
            request.setHeader('proxyHost','PROXYHOST URL');
            request.setHeader('proxySet','true');
    
            HttpResponse response = httpProtocol.send(request);


Note: The userName and Password will be filled from Custom setting.

I tried with and without the proxy header, I tried to turn the BASIC auth to Basic and many other little changes that didn't work.

I'm still getting this Error.

How can I know if it not blocked by Firewall? 

Any help or Idea to solve this issue

Thanks!
  • August 27, 2019
  • Like
  • 0
I exporting data to csv but when I read Excel file I see these characters:

Número factura
Logística
�rea factura

My code, controller:

var hiddenElement = document.createElement('a');         
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csvStringResult);
hiddenElement.target = '_self';

What should I do to see the characters correctly?

Thanks,

Noelia
Hello Everyone,

I have observed a wired behavior with "Blob.toPDF(<string>)" Salesforce Apex API's , this method strips off Chinese characters and there is no option to set character encoding, please find below the sample code.


String targetString = 'Before - 測試中文字 - After';

Attachment attachmentPDF = new Attachment();
attachmentPDF.parentId = '<parent record id>';
attachmentPDF.Name = 'Test' + '.pdf';
attachmentPDF.ContentType = 'application/pdf; charset=UTF-8';
attachmentPDF.body = Blob.toPdf(targetString); //This creates the PDF content
insert attachmentPDF;

I have also tried encoding Chinese character content to UTF-8 but this displays all the encoded characters in PDF,

String targetString = 'Before - 測試中文字 - After';
String encodedString = EncodingUtil.urlEncode(targetString,'UTF-8');
System.debug('##encodedString:-'+encodedString);

Attachment attachmentPDF = new Attachment();
attachmentPDF.parentId = '<parent record id>';
attachmentPDF.Name = 'Test' + '.pdf';
attachmentPDF.ContentType = 'application/pdf; charset=UTF-8';
attachmentPDF.body = Blob.toPdf(encodedString); //This creates the PDF content
insert attachmentPDF;

Please help.

Thanks
-Tejas(+91 9663266726)

Hello, I have a Force.com site in which I have APEX Forms. I wish to perform the following behaviour from one of my forms.

 

- On a user entering their form data the form action will post the data to an external site and as part of this redirect to this site as per traditional html forms specified with post.

 

I know I can post to an external site via the HTTP Request object by setting the request method to post but on completing my form action unless i use a PageReference and set the page reference to my external site I'm not sure how I can complete my task.

 

I wish to perform this in one POST and not have 2 steps (one posting via the HTTPRequest object and a separate PageReference redirecting to the site). Can this be achieved?

 

Thanks in advance.

Hello Everyone,

I have observed a wired behavior with "Blob.toPDF(<string>)" Salesforce Apex API's , this method strips off Chinese characters and there is no option to set character encoding, please find below the sample code.


String targetString = 'Before - 測試中文字 - After';

Attachment attachmentPDF = new Attachment();
attachmentPDF.parentId = '<parent record id>';
attachmentPDF.Name = 'Test' + '.pdf';
attachmentPDF.ContentType = 'application/pdf; charset=UTF-8';
attachmentPDF.body = Blob.toPdf(targetString); //This creates the PDF content
insert attachmentPDF;

I have also tried encoding Chinese character content to UTF-8 but this displays all the encoded characters in PDF,

String targetString = 'Before - 測試中文字 - After';
String encodedString = EncodingUtil.urlEncode(targetString,'UTF-8');
System.debug('##encodedString:-'+encodedString);

Attachment attachmentPDF = new Attachment();
attachmentPDF.parentId = '<parent record id>';
attachmentPDF.Name = 'Test' + '.pdf';
attachmentPDF.ContentType = 'application/pdf; charset=UTF-8';
attachmentPDF.body = Blob.toPdf(encodedString); //This creates the PDF content
insert attachmentPDF;

Please help.

Thanks
-Tejas(+91 9663266726)