You need to sign in to do that
Don't have an account?
Error calling PHP file
I am trying to call a php file using Apex class. I am attaching the Visual Force page and Apex class code and I am getting the following error " <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>502 Bad Gateway</title> </head><body> <h1>Bad Gateway</h1> <p>The proxy server received an invalid response from an upstream server.<br /> </p> </body></html> ". Any help is greatly appreciated.
<apex:page sidebar="false" controller="WebServ"> <apex:form > <apex:outputText value="{!Details}"></apex:outputText> </apex:form> </apex:page> public class WebServ { //The following example illustrates how you can use an authorization header with a request, and handle the response: public String getDetails() { Http http = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint('http://localhost/crm/accounts_mysql_tutorial.php'); req.setMethod('GET'); HttpResponse res = http.send(req); // Log the XML content System.debug(res.getBody()); return res.getBody(); } }
Thanks
Sue
Seriously?
You're trying to set the endpoint to localhost. That will try to point the Apex server at itself, which obviously won't work. Try pointing it at a web-accessible PHP page.