Hi Jitesh,
the client side looks fine.
On the server side, you might want to consume the header
parameter with the @HeaderParam annotation. E.g.
@GET
public Response getMethod(@HeaderParam("appKey") String appKey) {
...
}
~Jakub
On 06/29/2011 02:32 AM, Jitesh wrote:
>
> Sorry one correction --
>
> On serverside it is
>
> String appKey = request.getHeader("appKey") ;
>
> *From:*Jitesh Sinha -X (jisinha - Siliconweb Inc. at Cisco)
> *Sent:* Tuesday, June 28, 2011 5:26 PM
> *To:* 'Pavel Bucek-2 [via Jersey]'
> *Subject:* RE: How to set error response code from Rest web service
> and get it by Jersey client
>
> Thanks Pavel.
>
> How do we send header parameters through GET request?
>
> I am using following code and on server side I get appKey as null --
>
> This is client side code -
>
> Client client = Client.create();
>
> WebResource service = client.resource(URL);
>
> MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
>
> queryParams.add("transactionId",testCommand.getTransactionId()) ;
>
> ClientResponse response =
> service.queryParams(queryParams).header("appKey",appkey).get(ClientResponse.class);
>
> Server Side --
>
> String appKey = request.getParameter("appKey") ;
>
> Is something wrong in above code?
>
> Thanks
>
> -Jitesh
>
> *From:*Pavel Bucek-2 [via Jersey] [mailto:[hidden email]
> </user/SendEmail.jtp?type=node&node=6527169&i=0>]
> *Sent:* Tuesday, June 28, 2011 12:53 PM
> *To:* Jitesh Sinha -X (jisinha - Siliconweb Inc. at Cisco)
> *Subject:* Re: How to set error response code from Rest web service
> and get it by Jersey client
>
> http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/Response.html
> http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/ClientResponse.html
> http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e363
>
>
> On 6/28/11 9:31 PM, Jitesh Sinha -X (jisinha - Siliconweb Inc. at Cisco)
> wrote:
> > Is there a way to set error code and message by Rest API and then to
> > retrieve it by using Jersey client?
> > Currently I know only about Response.ok(variable).build() which is
> > supposed to be called when request has been processed ok.
> >
> > Thanks
> > -Jitesh
> >
>
> ------------------------------------------------------------------------
>
> *If you reply to this email, your message will be added to the
> discussion below:*
>
> http://jersey.576304.n2.nabble.com/How-to-post-a-file-and-other-form-fields-by-Jersey-client-tp6502947p6526332.html
>
>
> To unsubscribe from How to post a file and other form fields by Jersey
> client, click here.
>
>
> ------------------------------------------------------------------------
> View this message in context: RE: How to set error response code from
> Rest web service and get it by Jersey client
> <http://jersey.576304.n2.nabble.com/How-to-post-a-file-and-other-form-fields-by-Jersey-client-tp6502947p6527169.html>
> Sent from the Jersey mailing list archive
> <http://jersey.576304.n2.nabble.com/> at Nabble.com.