Options property does not add query parameters using Declarative Style

Describe the issue/error/question

I’m using declarative style to build my new node. I have a options type component that should add some queries to the request. But regardless of what option I select, nothing appears in the output.
This is the output:

?gadget=Skyroom&action=GetUsersN8N&from=&limit=1&offset=4&api_key=apikey-111111111111111111111111

And this is my properties part:

		properties: [
			{
				displayName: 'From Date',
				name: 'fromDate',
				type: 'dateTime',
				default: '',
				description: 'Returns customers that are created newer that this time',
				routing: { send: { property: 'from' } },
			},
			{
				displayName: 'Customer Type',
				name: 'type',
				type: 'options',
				default: '',
				options: [
					{
						displayName: 'All',
						name: 'All',
						value: '',
						routing: { send: { property: 'type', type: 'query' } },
					},
					{
						displayName: 'Free',
						name: 'Free',
						value: 'free',
						// action: 'Return customers with free plan',
						routing: { send: { property: 'type', type: 'query' } },
					},
					{
						displayName: 'Paid',
						name: 'Paid',
						value: 'paid',
						routing: { send: { property: 'type', type: 'query' } },
					},
				],
			},
			{
				displayName: 'Page Size',
				name: 'pageSize',
				description: 'Count of customers to retrieve in each page',
				type: 'number',
				default: 100,
				typeOptions: { minValue: 1, maxValue: 10000 },
				routing: { send: { property: 'limit' } },
			},
			{
				displayName: 'Page',
				name: 'page',
				description: 'The current page of pagination',
				type: 'number',
				default: 1,
				typeOptions: { minValue: 1, maxValue: 10000 },
				routing: {
					send: {
						property: 'offset',
						value: '={{($parameter["page"] -1) * $parameter["pageSize"] }}',
					},
				},
			},
		],

Information on your n8n setup

  • n8n version: 0.209.3

The correct way of adding a query with options is this:

{
	displayName: 'Free',
	name: 'Free',
	value: 'free',
	// action: 'Return customers with free plan',
	routing: { request: { qs: { type: 'free' } } },
},

Hi @rostamiani,
when using options instead of setting the routing property multiple times like this

set it only once at the root of your Customer Type parameter.

2 Likes

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