You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jozef Bouda <jo...@principal.cz> on 2022/04/29 05:44:00 UTC

path parameter from Camel HTTP endpoints

Hi, I have this issue, identical with issue on SO: https://stackoverflow.com/questions/32867844/clean-way-extract-path-parameters-from-camel-http-endpoints , but there is no satisfying answer and despite the fact, I was looking throw the internet, I have fount nothing, so sorry, if it is already answered but I would appreciate any help.

I am using apache karaf and apache camel.
In my blueprint, I have in default properties:
        <cm:default-properties>
            <cm:property name="someUri"      value="jetty:http://0.0.0.0:8092/someUri/{id}"/>
        </cm:default-properties>
Further more in camelContext I call my bean with that Uri:

<route id="somerRoute">
        <from uri="{{someUri}}"/>
            <process ref="restMyBean"/>
</route>
And my bean looks like:

<bean id="restMyBean" class="location.MyBean" activation="eager">
    <argument ref="someArgument"/>
</bean>

And in my process located in class MyBean, I would like to get {id} from someUri. Something like this:

String id = exchange.getIn().getHeader("id").toString();
But it is not working.

I know, that the id is in there, because postman return me 200 and I see in log:
jetty:http://0.0.0.0:8092/someUri/%7id%7D

But how to get it? Could you please give me an advice?

Thank you in advance and have a nice day.

Best regards.

Jozef Bouda
Junior Java Developer
Principal engineering s.r.o.
Office: Na hřebenech II 1718/8, Praha 4
Mobil: +420 771 253 806
Email:  jozef.bouda@principal.cz<ma...@principal.cz>
Web:   www.principal.cz<http://www.principal.cz/>

[cid:image001.jpg@01D85B99.5FCA5890]

[cid:image002.png@01D85B99.5FCA5890]


Re: path parameter from Camel HTTP endpoints

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

That requires you to use rest-dsl which supports {xxx} style in URIs.
If you use a regular <from> then you will not have that.



On Fri, Apr 29, 2022 at 8:10 AM Jozef Bouda <jo...@principal.cz>
wrote:

> Hi, I have this issue, identical with issue on SO:
> https://stackoverflow.com/questions/32867844/clean-way-extract-path-parameters-from-camel-http-endpoints
> , but there is no satisfying answer and despite the fact, I was looking
> throw the internet, I have fount nothing, so sorry, if it is already
> answered but I would appreciate any help.
>
>
>
> I am using apache karaf and apache camel.
>
> In my blueprint, I have in default properties:
>
>         <cm:default-properties>
>             <cm:property name="someUri"      value="jetty:
> http://0.0.0.0:8092/someUri/{id}"/>
>         </cm:default-properties>
>
> Further more in camelContext I call my bean with that Uri:
>
> <route id="somerRoute">
>         <from uri="{{someUri}}"/>
>             <process ref="restMyBean"/>
> </route>
>
> And my bean looks like:
>
> <bean id="restMyBean" class="location.MyBean" activation="eager">
>     <argument ref="someArgument"/>
> </bean>
>
>
>
> And in my process located in class MyBean, I would like to get {id} from
> someUri. Something like this:
>
> String id = exchange.getIn().getHeader("id").toString();
>
> But it is not working.
>
>
>
> I know, that the id is in there, because postman return me 200 and I see
> in log:
>
> jetty:http://0.0.0.0:8092/someUri/%7id%7D
>
>
>
> But how to get it? Could you please give me an advice?
>
>
>
> Thank you in advance and have a nice day.
>
>
>
> Best regards.
>
>
>
> *Jozef Bouda*
> Junior Java Developer
>
> *Principal engineering s.r.o.*
> *Office*: Na hřebenech II 1718/8, Praha 4
> *Mobil*: +420 771 253 806
> *Email*:  *jozef.bouda@principal.cz* <jo...@principal.cz>
> *Web*:   *www.principal.cz* <http://www.principal.cz/>
>
>
>
>
>
>
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2