Setting proxy on APIClient

How can I set a proxy for the APiclient?

There isn't currently any support for using a proxy in the SDK. I've created API-2319 to investigate adding it. We have some other work for the ApiClient scheduled this quarter and should be able to pile this on as long as the HTTP library supports it.

Is there any other work around we could do?

The only workaround is to implement it in a custom build of the SDK on your own.

@tim.smith Do you know when this is likely to be completed?

We have some other work for the ApiClient scheduled this quarter and should be able to pile this on as long as the HTTP library supports it.

Looks like ApiClient allows ClosableHttpClient to be set on it using setHttpClient(ClosableHttpClient). I am yet to try it out but is there any reason why this would not work?

protected void setupApiClientConfig() {
		client = Configuration.getDefaultApiClient();
		client.setAccessToken(getAccessToken());
		client.setBasePath(getBasePathUrl());
		client.setShouldThrowErrors(true);
		HttpHost proxy = new HttpHost(httpProxyHost, port, httpProxyProtocol);
			
		RequestConfig.Builder requestBuilder = RequestConfig.custom()
				.setProxy(proxy)
				.setConnectTimeout(connectionTimeout).setSocketTimeout(connectionTimeout)
				.setConnectionRequestTimeout(connectionTimeout);

		CloseableHttpClient httpClient = HttpClients.custom()
				.setDefaultRequestConfig(requestBuilder.build())
				.build();

		client.setHttpClient(httpClient);		 
	}

If that works for you, feel free to do it, but ApiClient encapsulates the HTTP libraries intentionally so that any changes we make to it don't break your code. If we make changes to it in the future, your code could stop working without warning.

Yes I understand and that was why I was asking. :slight_smile:

The changes your mention, I guess these will only impact new SDKs rather than old?

Also, I know you said this quarter but do you have any planned dates for these?

Correct. Once a version is published, it will never be changed. You can use an old version as long as it works.

There isn't a specific date at this time.

So if we don't upgrade the sdk, does this mean I could make the above change and it will keep on working?

It will work as long as it works. If there are API changes that are incompatible with the SDK, you'll have to upgrade your SDK version to be able to use those resources again.