HTTP node, curl --data-urlencode

Hi,

i have the follwing curl request, which i would like to rebuild in n8n, the problem is the columns parameter.

  curl \
    -v -G \
    --request GET \
    --write-out "\nxxx-status_code=%{http_code}\n" \
    --header "Authorization: Bearer $USERNAME $PASSWORD" \
    --header "Accept: */*" \
    --data-urlencode 'query={"op": "=", "left": "host_name", "right": "erp.it.local"}' \
    --data-urlencode 'columns=host_name' \
    --data-urlencode 'columns=description' \
    "$API_URL/domain-types/service/collections/all"
    )

Output:

{"links": [{"domainType": "link", "rel": "self", "href": "https://example.com/check_mk/api/1.0/objects/host/erp.it.local", "method": "GET", "type": "application/json"}], "domainType": "host", "id": "erp.it.local", "title": "erp.it.local", "members": {}, "extensions": {"host_name": "erp.it.local", "description": "ERP System"}}

Here is my n8n build:

I will not get the columns work, only the default value response by the api called “name”, tryed different styles.

Any Ideas?

N8N Version: 1.57.0

Thanks, Kr Christian

1 Like

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @ChristianV,

What happens if you added two Body parameters named columns with values host_name and description instead of as an array under one parameter?

@aya , 1st my fault was, that this is no body parameter, but a query parameter :man_facepalming: , cause its a get, i created before a post request.

But if a add one “columns” parameter now to request i worked, but if i add a second field, also with name “columns”, it will take only the last one.

if i add the fields direct to the url request, like:

“https://example.com/cnit/check_mk/api/1.0/objects/host/erp.it.local?columns=host_name&columns=display_name” it works.

Screenshot Fields:

Screenshot URL:

Ok, i found the solution:

Unbenannt5

and add
image

2 Likes

Nice you found the solution! :clap:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.