I have created a API in Restlet 2.4.2 java everything is working fine. I get this error when I try to call another API as a client in my ServerResource file.
here is my calling API as client code:
Client client = new Client(new Context(), Protocol.HTTPS);
client.getContext().getParameters().add("useForwardedForHeader","false");
ClientResource cr = new ClientResource("https://www.examples.com");
try{
cr.get(MediaType.APPLICATION_ALL).write(System.out);
} catch(ResourceException | IOException e) { e.printStackTrace(); }
Error I'm facing:
The protocol used by this request is not declared in the list of client connectors. (HTTPS/1.1). In case you are using an instance of the Component class, check its "clients" property.
I Tried to add httpclient library in pom.xml/maven but no luck
<dependency>
<groupId>org.restlet.jse</groupId>
<artifactId>org.restlet.ext.httpclient</artifactId>
<version>2.4.0</version>
</dependency>
Your problem is that you need to configure an HTTPS Connector to your restlet http client.
I made this simple sample project for you restlet https server/client sample
In this sample, you have a sample HTTPS server with a keystore with a self-signed certificate (for testing purpose) and an HTTPS client with same keystore/certificate configured.
Client code sample:
Client pom.xml dependencies:
Sample command line to create a test keystore:
For more information, read about Restlet- Client connectors and Restlet - HTTPS.
You can use Server/Client Resources too.