How to set query parameters in declarative nodes

Describe the problem/error/question

I try to develop my first n8n node in a descriptive way.
now I want to add an Endpoint which needs a query parameter. I don’t know where to add or define it actually.

This is my operation:

{
		displayName: 'Operation',
		name: 'operation',
		type: 'options',
		default: 'getAll',
		noDataExpression: true,
		displayOptions: {
			show: {
				resource: [
					'contact',
				],
			},
		},
		options: [
			{
				name: 'Contact Customer Number Availability Check',
				value: 'contactCustomerNumberAvailabilityCheck',
				description: 'Checks if a given customer number is available or already used',
				action: 'Contact customer number availability check',
				routing: {
					request: {
						method: 'GET',
						url: 'Contact/Mapper/checkCustomerNumberAvailability',
					},
					send: {
						property: 'customerNumber',
						type: 'query'
					}
				},
			},
		]
	}

This is the field definition:

{
		displayName: 'Customer Number',
		name: 'customerNumber',
		description: 'The customer number to be checked',
		type: 'string',
		required: true,
		default: '',
		displayOptions: {
			show: {
				resource: [
					'contact',
				],
				operation: [
					'contactCustomerNumberAvailabilityCheck',
				],
			},
		},

	},

I get an 500 error but I don’t know how to get more information about the error. If I try to call that endpoint with Insomnia I get a 500 error if the queryparameter is missing. So I asume it is not attached automatically.
I also of other Endpoints for this resource which are working fine. So I know that authentication and the basic options are set up correctly.

Btw. is there a in depth documentation for the declarative node development? Or do you know a complex node which is defined in the declarative way, so that I could take a look over there?

Cheers.

Found the solution by myself:

{
		displayName: 'Customer Number',
		name: 'customerNumber',
		description: 'The customer number to be checked',
		type: 'string',
		required: true,
		default: '',
		displayOptions: {
			show: {
				resource: [
					'contact',
				],
				operation: [
					'contactCustomerNumberAvailabilityCheck',
				],
			},
		},
		routing: {
			send: {
				type: 'query',
				property: 'customerNumber',
				value: '={{$value}}',
			}
		}
	},

The routing.send did the trick in the field declaration.

I also found a node in declarative style. It is the brevo node.

Cheers

3 Likes

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