1
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPut put = new HttpPut("url");
put.addHeader("X-Apikey","");
StringEntity se = new StringEntity(version.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
put.addHeader("Accept", "application/json");
put.addHeader("Content-type", "application/json");
put.setEntity(se);
try{
HttpResponse response = httpClient.execute(put, localContext);
HttpEntity entity = response.getEntity();
在這裏,我需要幫助以OkHttpClient替換HttpClient及其所有後續參數。如何在下面的Apache HttpClient代碼上使用OkHttpClient
是的,它可以創建新的HTTP客戶端,但無法在PUT,POST,GET merhod中執行。它顯示「.excute(put)無效。你能幫我實現這個URL連接嗎? – user3145687
感謝您修復我的錯字,jw! –
請詳細解釋一下嗎? – user3145687