Quantcast

How do I authenticate with Camel?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How do I authenticate with Camel?

nizhnegorskiy
I need to send a POST request with token. Something like this:
curl -H "Authorization: [token]" -X POST --data-binary @filename.json 'http://myhost.com/someurl'

I have the following code:
                context.addRoutes(new RouteBuilder() {
                        public void configure() {
                                from("file:data/out?fileName=filename.json&noop=true")
                                .setHeader(Exchange.HTTP_METHOD,
                                                constant(org.apache.camel.component.http.HttpMethods.POST))
                                .to("http://myhost.com/someurl");
                }
How do I add this [token] to the request?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How do I authenticate with Camel?

Richard Kettelerij
Hi,

Welcome to the Camel community. Try the following:

context.addRoutes(new RouteBuilder() {
        public void configure() {
                from("file:data/out?fileName=filename.json&noop=true")
                .setHeader(Exchange.HTTP_METHOD,

constant(org.apache.camel.component.http.HttpMethods.POST))
        .setHeader("Authorization", constant("mytoken"))
                .to("http://myhost.com/someurl");
}

Note the added "Authorization" header. Camel automatically translates Camel
headers to transport specific (in this case HTTP) headers.

Regards,
Richard

On Fri, Jul 15, 2011 at 11:51 AM, nizhnegorskiy <[hidden email]>wrote:

> I need to send a POST request with token. Something like this:
> curl -H "Authorization: [token]" -X POST --data-binary @filename.json
> 'http://myhost.com/someurl'
>
> I have the following code:
>                context.addRoutes(new RouteBuilder() {
>                        public void configure() {
>
>  from("file:data/out?fileName=filename.json&noop=true")
>                                .setHeader(Exchange.HTTP_METHOD,
>
>  constant(org.apache.camel.component.http.HttpMethods.POST))
>                                .to("http://myhost.com/someurl");
>                }
> How do I add this [token] to the request?
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-do-I-authenticate-with-Camel-tp4590064p4590064.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How do I authenticate with Camel?

nizhnegorskiy
Thanks!
Loading...