You need to sign in to do that
Don't have an account?

Connecting to the sever through apex
We can connect to an external server through HTML code which is written below:
<html>
<FORM METHOD="POST" ACTION="https://www.signom.com/test-server/authentication/Service.signom">
<INPUT NAME="version" TYPE="text" VALUE="1.0"> </INPUT>
<INPUT NAME="requestId" TYPE="text" VALUE="2010028"></INPUT>
<INPUT NAME="customerId" TYPE="text" VALUE="TEST_SALESSEEKERS"></INPUT>
<INPUT NAME="queryFlags" TYPE="text" VALUE="enable-strong-identification+return-ssn+return-user-name">
<INPUT type="submit" value="Send"></INPUT>
</FORM>
</html>
But connecting to the same server with Apex code is creating problems. We are getting :
System.HttpRequest[Endpoint=https://www.signom.com/test-server/authentication/Service.signom, Method=POST]
System.HttpResponse[Status=Moved Temporarily, StatusCode=302]
Following is the Apex code snippet:
req.setEndpoint('https://www.signom.com/test-server/authentication/Service.signom');
req.setMethod('POST');
Http http = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
req.setBody('version='+EncodingUtil.urlEncode(version, 'UTF-8')+'&requestId='+EncodingUtil.urlEncode(requestId, 'UTF-8')+'&customerId='+EncodingUtil.urlEncode(customerId, 'UTF-8')+'&queryFlags='+EncodingUtil.urlEncode(queryFlags, 'UTF-8'));
I could not understand why this error is coming.
please suggest.
I'd be surprised if Apex was having any effect on the server responding with a 302.
The 302 status code means that the resource you have requested has been temporarily relocated. In practice this is a very common way of redirecting the browser to a different page and changing the request to a GET. I'd imagine that the server carries out whatever processing is required based on the form and then redirects the browser to the results page.
The browser will automatically follow this redirect, but an HTTPRequest will simply return it to your code.
try using above HTML in vf page instead of apex.
I also was facing similar problem in my one of the projects, but with some other 3rd-party app.