How can I achieve correctly formatted output using cURL with "Execute Command" node?


I am trying to use the “Execute Command” node which makes a cURL request.
I am running with N8N community 0.168.2 on premises.

The output of any cURL command I’d do on n8n:

    "exitCode": 0,
    "stderr": "",
    "stdout": "{"query": "some JSON"}"

The thing is that I only want what’s inside the stdout , not the exitCode nor the stderr. Basically, I just want the request to output the data just like this:

    "query": "some JSON"

How can I do this using n8n?

P.S: When doing such a cURL request in my local machine terminal, I get the desired output, but not when using the n8n Execute command node.


Have you tried the same with the HTTP Request node?

The thing is with the HTTP Request node you can pick the Output as per your choice.

Of if you want to go ahead with Execute Command Node.

You have to pipe the output into something like jq

curl | jq '.[0].stdout'
1 Like

Welcome to the community @bjoliveau !

I’m curious why you are using the execute command node instead of using the HTTP request node instead? There is some adjusting to the different interface but I find it works well. Here is a post where I convert a cURL request to HTTP request.

However, it is possible to accomplish what you are trying to do with the execute command node. This workflow shows what you need to do, but the specific function you will want to add after the execute command to parse the json is below:

Saw your reply after I posted! :laughing:

1 Like

You can also do {{$json['stdout']}} in the next node to only use the stdout data.

Hi @bjoliveau welcome to n8n :tada:

here are 3 examples on how to get the the data you want, depending on where you are or in which node type …

1 Like