简体   繁体   中英

how to pass 2 parameters in Get method using java

My URL is like -

https://api.insideview.com/api/v1/people/abcdef?active=true

here the arguments passed are people=abcdef and active=true

How can I incorporate both the parameters using get method-

My code is like-

public PeopleDetailInstance peopledetail(String peopleId) {
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod("https://api.insideview.com/api/v1/people/"+peopleId); 
... peopledetail(String peopleId, Boolean active) {
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod("https://api.insideview.com/api/v1/people/"+peopleId + "&active=" + active)

Edit - sorry by the bad format. Im in phone.

Now sure where your api url ends but query string should be
your url + ?parameter1="value"&parameter2="value"
https://yourApiUrl?people=peopleId&active=true

Try this

public PeopleDetailInstance peopledetail(String peopleId) {    
    URIBuilder builder = new URIBuilder();
    builder.setScheme("https")
        .setHost("api.insideview.com")
        .setPath("/api/v1")
        .setParameter("people", peopleId)
        .setParameter("active", "true")
    URI uri = builder.build();
    HttpGet httpget = new HttpGet(uri);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM