You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Suganya <su...@gmail.com> on 2015/09/18 10:11:02 UTC

curl

Hi,
'
Is it possible to run curl command in camel routes?




--
View this message in context: http://camel.465427.n5.nabble.com/curl-tp5771624.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: curl

Posted by Suganya <su...@gmail.com>.
I tried below,

<setBody><simple>testingsimple></setBody>
<to uri="file:/003/?fileName=temp.json" />

but getting the below error stating 

 caught: org.apache.camel.language.bean.RuntimeBeanExpressionException:
Failed to invoke method: .stdout on null due to:
org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: stdout on null due to:
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
stdout not found on bean: testing of type: java.lang.String.
Exchange[Message: testing]:
org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: .stdout on null due to:
org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: stdout on null due to:
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
stdout not found on bean: testing of type: java.lang.String.
Exchange[Message: testing]

Please help me out. I tried many other stuffs as well but none seem to work.



--
View this message in context: http://camel.465427.n5.nabble.com/curl-tp5771624p5772195.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: curl

Posted by Suganya <su...@gmail.com>.
Hi Asaf, Claus,

thanks for your replies.

&quot did not work and i tried few other escape stuffs as well but none seem
to work. 

The only way that i was able to pass the json is by using a temporary file.

<setHeader headerName="CamelExecCommandArgs">
					<simple>--silent --sslv3 --verbose --cacert {{cacertFile}} --key
{{keyFile}} --cert {{certFile}} -H Content-Type:application/json -u {{user}}
-X POST {{host}}/tenants -d @/003/temp.json</simple>
				</setHeader>
				<to uri="exec:curl"/>

*In my case, the JSON needs to be framed dynamically. Its not a static json
content. *

*Any idea on how to frame the JSON content dynamically in camel ?*

I have this as the json string --

<setHeader headerName="JSON1">
    <xpath resultType="java.lang.String">/response/JSONString</xpath>
</setHeader>

*I get this above JSON string from one of the external components.

how to write this string to the file and rewrite it everytime?*





--
View this message in context: http://camel.465427.n5.nabble.com/curl-tp5771624p5772180.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: curl

Posted by Asaf Mesika <as...@gmail.com>.
 I think you didn't escape the quotation marks inside the -d value which is
the JSON. Try
<to uri="exec:curl?args=--silent --cacert {{cacertFile}} --key {{keyFile}}
--cert {{certFile}} -H 'Content-Type: application/json' -X POST
{{host}}/tenants -d '{&quot;id&quot;:&quot;12353200&quot;,&quot;name&quot;:
&quot;tenant1&quot;,&quot;description&quot;:
&quot;tenant description&quot;}' -u {{user}} --sslv3"/>

or better - store this json as is in a file "/tmp/1.json", and use
--data-binary @/tmp/1.json to send it in curl.


On Mon, Sep 28, 2015 at 1:28 PM, Suganya <su...@gmail.com> wrote:

> Hi,
>
> Thanks for your reply.
>
> The GET command is working using the exec component.
>
> But I am stuck with the POST or the PUT command. The input data is in JSON
> format. But I am unable to pass it.
>
> Where am I going wrong? below is the command.
>
> <to uri="exec:curl?args=--silent --cacert {{cacertFile}} --key {{keyFile}}
> --cert {{certFile}} -H 'Content-Type: application/json' -X POST
> {{host}}/tenants -d '{"id":"12353200","name": "tenant1","description":
> "tenant description"}' -u {{user}} --sslv3"/>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/curl-tp5771624p5772053.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: curl

Posted by Suganya <su...@gmail.com>.
Hi,

Thanks for your reply.

The GET command is working using the exec component.

But I am stuck with the POST or the PUT command. The input data is in JSON
format. But I am unable to pass it.

Where am I going wrong? below is the command.

<to uri="exec:curl?args=--silent --cacert {{cacertFile}} --key {{keyFile}}
--cert {{certFile}} -H 'Content-Type: application/json' -X POST
{{host}}/tenants -d '{"id":"12353200","name": "tenant1","description":
"tenant description"}' -u {{user}} --sslv3"/>




--
View this message in context: http://camel.465427.n5.nabble.com/curl-tp5771624p5772053.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: curl

Posted by Claus Ibsen <cl...@gmail.com>.
You can use the exec component
http://camel.apache.org/exec

On Fri, Sep 18, 2015 at 10:11 AM, Suganya <su...@gmail.com> wrote:
> Hi,
> '
> Is it possible to run curl command in camel routes?
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/curl-tp5771624.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition