带参数的 apache HttpGet

apache HttpGet with params

我要执行这个URL:

curl -X DELETE -H "Authorization: Basic myToken=" "https://foo.com/iot/developers/apps.json?id=173217639" 在服务器端删除了 1 个对象。

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;

HttpParams myHttpParams=new BasicHttpParams();
        myHttpParams.setParameter("id", "173217639");
        HttpClient client = HttpClientBuilder.create().build();     
        HttpGet request = new HttpGet("foo.com/iot/developers/apps.json");
        request.setParams(myHttpParams);
        request.addHeader("Authorization", "Basic myToken=");
    HttpResponse response = client.execute(request);

但结果并不例外(服务器端没有任何反应)

您需要使用 HttpDelete 而不是 HttpGet