Hello, i want to use Elasticsearch API (since there is no node yet) and with this curl example i want to do the same with HTTP Request node.
> curl -X GET “localhost:9200/_search?pretty” -H ‘Content-Type: application/json’ -d’
{
"query": {
"match": {
"message": {
"query": "to be or not to be",
"operator": "and",
"zero_terms_query": "all"
}
}
}
Notice that the important thing is -d parameter which sets the body and i want to do the same but i can’t find a way.
Check the example below.
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"requestMethod": "POST",
"url": "https://webhook.site/d45c1b68-ecab-405e-8429-57cbec151fe5",
"options": {},
"bodyParametersUi": {
"parameter": [
{
"name": "query",
"value": "={{$node[\"Set\"].json}}"
}
]
}
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
700,
300
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "match.message",
"value": "={{{ \"query\": \"to be or not to be\", \"operator\": \"and\", \"zero_terms_query\": \"all\" } }}"
}
]
},
"options": {}
},
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
470,
300
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
},
"Set": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}
Perfect, that worked for me but now i need send this data.
{ “aggs”: {
“ip_count”: {
“value_count”: {
“field”: “clientip”
}
}
}
}
Check the example below:
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"requestMethod": "POST",
"url": "https://webhook.site/d45c1b68-ecab-405e-8429-57cbec151fe5",
"options": {},
"bodyParametersUi": {
"parameter": [
{
"name": "aggs",
"value": "={{$node[\"Set\"].json}}"
}
]
}
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
830,
310
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "ip_count",
"value": "={{{\n \"value_count\": {\n \"field\": \"clientip\"\n }\n}}}"
}
]
},
"options": {}
},
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
570,
310
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
},
"Set": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}
Thanks, that worked and made it clear (sadly mi index doesnt accept aggregations) to future parameters. Thanks.