0

I want to get data from this API: http://countryapi.gear.host/v1/Country/getCountries. I need that user can write name of the Country in JTextField and get NativeName and CurrencyCode in JTextArea.

I have such a code, it returns data only for Country which I write in HttpGet: HttpGet request = new HttpGet("http://countryapi.gear.host/v1/Country/getCountries?pName=Australia");.

But how can I do that user can write the Country and get info for it which he wants?

Viola
  • 487
  • 1
  • 10
  • 33

1 Answers1

1

Try to use this

request = new HttpGet(
        "http://countryapi.gear.host/v1/Country/getCountries?pName=country"
                .replaceAll("country", yourTextField.getText())
);
Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
  • Or use Apache `URIBuilder` to build... look here: https://stackoverflow.com/questions/9907161/commons-httpclient-adding-query-string-parameters-to-get-post-request – Vadim Dec 01 '17 at 20:36