You need to sign in to do that
Don't have an account?
Krisztian
Https request with apex class
Please help me to wirite a class that can send a https request.
I create successful a https request based on:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm
but I do not have any idea to create a https request.
Seems endpoint you provided isn't certified with an ssl certificate signed by some verified certificate authority (CA). Salesforce will therefore not accept the certificate and you get the exception you're seeing. You can either switch to unencrypted http or buy a proper certificate or try making your web service talk to SF with certificates which are issued by a CA trusted by SF.
This is of course only possible if you control the endpoint you're trying to talk to. Check out: http://wiki.developerforce.com/page/Making_Authenticated_Web_Service_Callouts_Using_Two-Way_SSL
Here's a pointer as to which CA's are accepted as valid authorities by SF: http://success.salesforce.com/ideaView?id=08730000000JziE
Hope it helps!
All Answers
Please refer following help links and thread with sample code for this:
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000977iIAA
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm
I am sorry, I made a typo :(
I create successful a http request based on:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm
but I do not have any idea to create a https request.
Do you mean "http response", as you have created http request?
If I siply modify the endpoint to https://..... I catch an exception:
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Seems endpoint you provided isn't certified with an ssl certificate signed by some verified certificate authority (CA). Salesforce will therefore not accept the certificate and you get the exception you're seeing. You can either switch to unencrypted http or buy a proper certificate or try making your web service talk to SF with certificates which are issued by a CA trusted by SF.
This is of course only possible if you control the endpoint you're trying to talk to. Check out: http://wiki.developerforce.com/page/Making_Authenticated_Web_Service_Callouts_Using_Two-Way_SSL
Here's a pointer as to which CA's are accepted as valid authorities by SF: http://success.salesforce.com/ideaView?id=08730000000JziE
Hope it helps!
The problem was in the ssl certificate.