W L
W L

Reputation: 11

Spring RestTemplate throws IllegalArgumentException: not a valid HTTP URL

java.lang.IllegalArgumentException: [https://localhost/pcap/search?stime=20110930%2E000000&etime=20110930%2E235959&bpf=tcp

Here is the call I made using Spring RestFul Template:

final PcapSearchResponse pcapSearchResult = restTemplate.postForObject(
    nPulseApiUris.get(2), null, PcapSearchResponse.class, sTime, eTime, bpf);

I don't understand why that is a bad URL? I used UTF-8 to encode the "." character but I am not sure why my URL is still invalid.

Your help is greatly appreciated!

Thank you for your help!!!

Upvotes: 1

Views: 12702

Answers (1)

Bozho
Bozho

Reputation: 597016

The documentation of RestTemplate mentions that:

Furthermore, the String-argument methods assume that the URL String is unencoded.

So, when passing your URL as string, don't encode it. Spring will take care of that.

Upvotes: 5

Related Questions