1

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!!!

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

13 Comments

Hi Bozho, thank you very much for your response. Yes I did not encode the url. The URL looks like the following in my code in which the nPulseApiUris is of type List<String>: https://localhost/pcap/search?stime={stime}&amp;etime=${etime}&amp;bpf=${bpf} Your help is greatly appreciated!
Hi @Bozho, I greatly appreciate your response. My request parameters which I am trying to post to the RESTful service URI https://localhost/pcap/searchare: stime=20110930.000000 etime=20110930.235959 bpf=tcp Thank you so much Bozho!
Looks ok. Now get rid rid of amp
If I get rid of the ampersand, I'm not sure how I'm going to post those parameters to the RESTful service URI. Hence I thought if I append it, that would work. Thank you for your help!!
Don't remove the whole amperasnd, but don't write it encoded. So & instead of &amp;
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.