I need to configure a proxy to send JSON using POST using proxyHost and proxyPort.
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); Proxy proxyTest = new Proxy(Proxy.Type.HTTP,new InetSocketAddress("proxy", proxyPort)); OkHttpClient client = new OkHttpClient() .proxy(proxyTest) .build();
When I try to use the proxy test, which I saw in some answers here, it indicates an error:
The proxy () method in type OkHttpClient is not applicable for arguments (proxies)
Iam using OKHTTP 3.3.1 (okhttp3)
My question is: what should I do? I have done several such tests:
OkHttpClient.Builder builder = new OkHttpClient.Builder ();
builder.proxy (proxyTest);
client.setProxy (proxyTest)
OkHttpClient client = builder.build ();
But so far nothing is working.
Thank you for your time!
Matheus bica
source share