Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!ipa.eternal-september.org!.POSTED!not-for-mail From: Jukka Lahtinen Newsgroups: comp.lang.java.programmer Subject: Re: Rest parameter without value Date: Mon, 17 Oct 2016 09:50:41 +0300 Organization: A noiseless patient Spider Lines: 35 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ipa.eternal-september.org; posting-host="1426077118a40e478a39e8679e6194b7"; logging-data="23712"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BQyl5TavieFoMbhD5AwVP" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cancel-Lock: sha1:nfsI30oYTcMiKnBjUVGrG9Eut1s= sha1:/b09TDffNSBdC2q5yKXDeQsp+uE= X-no-archive: yes Xref: csiph.com comp.lang.java.programmer:35795 Jukka Lahtinen writes: > Arne Vajhøj writes: >> On 10/14/2016 8:28 AM, Jukka Lahtinen wrote: >>> Now the request with a path parameter should in some occasions contain a >>> parameter without a value. >>> What I have tried looks essentially like this: >>> String url = "http://machine/path/v3.0/{keyvalue}"; > I guess I'll try if this works when I just use > url = "http://machine/path/v3.0/{keyvalue}?foo"; > when the valueless parameter is needed. When I tested this against the real server application, it turned out not to work as I expected. I got it working when I used something like this: UriBuilder builder = UriBuilder.fromUri( url ).path( path ). resolveTemplate( "keyvalue", keyvalue ); WebTarget target = client.target( builder ); if (foo) { target = target.queryParam( "foo", Boolean.TRUE); } Response resp = target.request().headers( buildHeaders()).get(); In other words, the QueryParam wasn't (or at least didn't need to be) valueless after all, it worked with a Boolean value. This may be a bug in the documentation of the server application. In this case, the parameter that looked valueless isn't a key value, but a switch that controls what the server application does if it doesn't find the data in its database. -- Jukka Lahtinen