Leiste mit Community-Erfolgen erweitern.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

HttpClient not using proxy set in AEM

Avatar

Level 2

Hello,

My application need to make a REST call to the external world.

I use Apache HttpClient to do. I expect that the call goes through proxy set in AEM, but it doesn't, it directly tries to fetch data.

I do not want to add explicit configuration for proxy in my application, it should just use default proxy set inAEM.

Any ideas how to do it?

Thanks,
Abhijeet

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Level 10

Refer this -

HttpClient is not passing through proxy

Get the factory from OSGI itself rather than creating a custom instance of HTTPClient where you would need to read the OSGI properties on your own.

//Add the HTTP Client Builder Factory reference like below in your OSGI component.

@Reference

private HttpClientBuilderFactory httpFactory; //in your method then you can get the HTTP Client object.

HTTPClient client =  httpFactory.newBuilder().build();

Lösung in ursprünglichem Beitrag anzeigen

1 Antwort

Avatar

Korrekte Antwort von
Level 10

Refer this -

HttpClient is not passing through proxy

Get the factory from OSGI itself rather than creating a custom instance of HTTPClient where you would need to read the OSGI properties on your own.

//Add the HTTP Client Builder Factory reference like below in your OSGI component.

@Reference

private HttpClientBuilderFactory httpFactory; //in your method then you can get the HTTP Client object.

HTTPClient client =  httpFactory.newBuilder().build();