Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35753
| From | Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Rest parameter without value |
| Date | 2016-10-14 15:28 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <m3lgxr8681.fsf@saunalahti.fi> (permalink) |
I have been working with java, but REST is new to me.
Now I am working on a REST client for the first time.
I have already managed to use a rest request with a path parameter and
another one with query parameters.
Now the request with a path parameter should in some occasions contain a
parameter without a value.
I have used an url like this:
http://machine/path/v3.0/keyvalue
(where "keyvalue" is the variable path parameter and the url is
otherwise constant)
and in another context I should use
http://machine/path/v3.0/keyvalue?foo
Where "foo" is a constant parameter name.
But I haven't figured out how to add a parameter without a value!
What I have tried looks essentially like this:
String url = "http://machine/path/v3.0/{keyvalue}";
Private javax.ws.rs.Client client; // initialized in the constructor
..
private Object makeCall(String keyvalue, boolean b) {
UriBuilder builder = UriBuilder.fromUri( url ).path( path ).
resolveTemplate( "keyvalue", keyvalue );
WebTarget target = client.target( builder );
if (b) {
target = target.queryParam("foo", "");
}
Response resp = target.request().headers(makeHeaders()).get();
Object ret = null;
..
// resp handling not shown here
..
return ret;
}
Debugging this, I lookd at target after the target.queryParam call and
noticed that target contains a ResteasyUriBuilder object uriBuilder,
where the attribute "query" now contains "foo=".
So this apparently will make the actual url look like this:
http://machine/path/v3.0/keyvalue?foo=
But I need it without the equals at the end. How do I do that?
I also tried passing null to the target.queryParam call instead of the
empty String,
target = target.queryParam("foo", null);
but that way target.uriBuildeer.query remains null.
--
Jukka Lahtinen
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Rest parameter without value Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2016-10-14 15:28 +0300
Re: Rest parameter without value Arne Vajhøj <arne@vajhoej.dk> - 2016-10-14 14:49 -0400
Re: Rest parameter without value Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2016-10-17 08:48 +0300
Re: Rest parameter without value Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2016-10-17 09:50 +0300
Re: Rest parameter without value 4ndre4 <626401fd-4bc7-4f8f-b641-563ae0f72920@626401fd-4bc7-4f8f-b641-563ae0f72920.invalid> - 2016-10-14 21:16 +0100
Re: Rest parameter without value Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2016-10-17 08:30 +0300
csiph-web