You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nizhnegorskiy <ni...@mail.ru> on 2011/07/15 11:51:57 UTC
How do I authenticate with Camel?
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.
Re: How do I authenticate with Camel?
Posted by nizhnegorskiy <ni...@mail.ru>.
Thanks!
--
View this message in context: http://camel.465427.n5.nabble.com/How-do-I-authenticate-with-Camel-tp4590064p4599426.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How do I authenticate with Camel?
Posted by Richard Kettelerij <ri...@gmail.com>.
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 <ni...@mail.ru>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.
>