function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Salesforce 10026Salesforce 10026 

HTTP post request is not leaving salesforce servers

Immediately after the callout request I get a callout response "System.HttpResponse[Status=Forbidden, StatusCode=403]" even though I have already configured the domain in the remote site configurations and verified the request, it works fine in any other client but salesforce. I've already verified that the request is not hitting the server in the other side of the request, so it must not be leaving salesforce for some reason.

Here is my request:

public String calloutNcall() {
       
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
       
        req.setEndpoint('http://ncall.myinstance.com.br/ncall/servicos/click2call.php');
        req.setMethod('POST');
        params = 'magic=1333';
        params += '&ramal' + ramal;
        params += '&numero' + ani;
        params += '&espera=60';
        params += '&nome=NCall';
        req.setBody(params);
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded'); 
       
        try {
            res = http.send(req);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
        }
        System.debug(res.getBody());
        this.result = res.getBody();
        return null;
      }
}

Here is the response:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>ERROR: The requested URL could not be retrieved</title> <style type="text/css"><!-- /* Stylesheet for Squid Error pages Adapted from design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License */ /* Page basics */ * { font-family: verdana, sans-serif; } html body { margin: 0; padding: 0; background: #efefef; font-size: 12px; color: #1e1e1e; } /* Page displayed title area */ #titles { margin-left: 15px; padding: 10px; padding-left: 100px; background: url('http://www.squid-cache.org/Artwork/SN.png') no-repeat left; } /* initial title */ #titles h1 { color: #000000; } #titles h2 { color: #000000; } /* special event: FTP success page titles */ #titles ftpsuccess { background-color:#00ff00; width:100%; } /* Page displayed body content area */ #content { padding: 10px; background: #ffffff; } /* General text */ p { } /* error brief description */ #error p { } /* some data which may have caused the problem */ #data { } /* the error message received from the system or other software */ #sysmsg { } pre { font-family:sans-serif; } /* special event: FTP / Gopher directory listing */ #dirmsg { font-family: courier; color: black; font-size: 10pt; } #dirlisting { margin-left: 2%; margin-right: 2%; } #dirlisting tr.entry td.icon,td.filename,td.size,td.date { border-bottom: groove; } #dirlisting td.size { width: 50px; text-align: right; padding-right: 5px; } /* horizontal lines */ hr { margin: 0; } /* page displayed footer area */ #footer { font-size: 9px; padding-left: 10px; } body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; } --></style> </head><body id=ERR_ACCESS_DENIED> <div id="titles"> <h1>ERROR</h1> <h2>The requested URL could not be retrieved</h2> </div> <hr> <div id="content"> <p>The following error was encountered while trying to retrieve the URL: <a href="http://ncall.myinstance.com.br/ncall/servicos/click2call.php">http://ncall.myinstance.com.br/ncall/servicos/click2call.php</a></p> <blockquote id="error"> <p><b>Access Denied.</b></p> </blockquote> <p>Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.</p> <p>Your cache administrator is <a href="mailto:support@salesforce.com?subject=CacheErrorInfo%20-%20ERR_ACCESS_DENIED&amp;body=CacheHost%3A%20proxy-dfw.net.salesforce.com%0D%0AErrPage%3A%20ERR_ACCESS_DENIED%0D%0AErr%3A%20%5Bnone%5D%0D%0ATimeStamp%3A%20Thu,%2006%20Oct%202016%2014%3A10%3A29%20GMT%0D%0A%0D%0AClientIP%3A%2010.247.62.9%0D%0A%0D%0AHTTP%20Request%3A%0D%0APOST%20%2Fncall%2Fservicos%2Fclick2call.php%20HTTP%2F1.1%0AUser-Agent%3A%20SFDC-Callout%2F37.0%0D%0ASFDC_STACK_DEPTH%3A%201%0D%0AContent-Type%3A%20application%2Fx-www-form-urlencoded%0D%0ACache-Control%3A%20no-cache%0D%0APragma%3A%20no-cache%0D%0AHost%3A%20ncall.myinstance.com.br%0D%0AAccept%3A%20text%2Fhtml,%20image%2Fgif,%20image%2Fjpeg,%20*%3B%20q%3D.2,%20*%2F*%3B%20q%3D.2%0D%0AProxy-Connection%3A%20keep-alive%0D%0AContent-Length%3A%2058%0D%0AX-Forwarded-For%3A%2010.247.221.59%0D%0A%0D%0A%0D%0A">support@salesforce.com</a>.</p> <br> </div> <hr> <div id="footer"> <p>Generated Thu, 06 Oct 2016 14:10:29 GMT by proxy-dfw.net.salesforce.com (squid)</p> <!-- ERR_ACCESS_DENIED --> </div> </body></html>
Tejas KardileTejas Kardile
What is your authentication mechanism, Are you sending any certificate in service call or your authenticating using user name and password?
 
Salesforce 10026Salesforce 10026
@Tejas Kardile there's no authentication needed. I've tried doing a GET to the directory http://ncall.myinstance.com.br/ncall/servicos/ without any of the parameters and still got the same error 403. But if I do a GET to any other random URL it works fine. I've also tried, disabling the protocol security in remote site settings, but still no sucess. The endpoint I'm trying to reach is our domain in our VoIP company, where our instance is hosted, when I enter the directory http://ncall.myinstance.com.br/ncall/servicos/ I can see a message at the bottom Apache/2.2.22 (Debian) Server at ncall.myinstance.com.br Port 80 it can be that salesforce is not "seeing" this endpoint? Some DNS configuration missing? Again, if I do the request via Browser, Postman or any other UI it works. The HTML error I get looks like is coming from salesforce, but I can't find out what configuration I'm missing.
NagendraNagendra (Salesforce Developers) 
Hi Salesforce 10026,


If you save the message as HTML file and view it does look like an error that could be generated within Salesforce. Did you change the endpoint to post here as your posted one gives "ncall.myinstance.com.br’s server DNS address could not be found" (doing a GET) so will not work.

And also check your remote site settings. That's what the error appears to be saying. Did you enable "disable protocol security"

Best Regards,
Nagendra.P

 
ellospiderellospider
Firewall could  be blocking your callout. Check with your networking team if Salesforce IPs were whitelisted. More details on this article.
https://help.salesforce.com/HTViewSolution?id=000003652 
 
Bruce Stewart 27Bruce Stewart 27
Did you get this resolved?  I'd suspect some firewall issue(s), too, as in my situation Postman works from a console to endpoint app, but SF raeacts as yours did Forbidden / 403.  Looking at your code as you concatenated params, why did some contain key=value and some just key + variable.  Is the = in the variable string?