Hi all,
I’m trying to develop a new node using the declarative style and I’m running into a few issues with controlling the characters that get escaped as a string field is processed by n8n.
Describe the problem/error/question
I’ve got this code block here for my query string parameters (See at the bottom). In short, my goal is to allow a fixed collection so I don’t have to add UI elements for every single filtering option.
The Problem
I need to be able to parse the following URL query string to the API endpoint:
/indicators?$filter=action+eq+'AlertAndBlock'
When I try this in the UI this is what I enter.
Ultimately this is the escaped URL that n8n produces.
/indicators?%24filter=action%2Beq%2B%27AlertAndBlock%27
The API endpoint returns the following issue:
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. Syntax error: character '+' is not valid at position 9 in 'action eq+'AlertAndBlock''.",
"details": []
}
}
Question
What’s the best way to handle what gets escaped by n8n on the input field? Ideally, I’d like to be able to ensure the “+” symbol isn’t escaped. Is there an easy way to do that?
Thanks for your assistance!
List of filtering options
The OData’s $filter
query is supported on: application
, createdByDisplayName
, expirationTime
, generateAlert
, title
, rbacGroupNames
, rbacGroupIds
, indicatorValue
, indicatorType
, creationTimeDateTimeUtc
, createdBy
, action
, and severity
properties.
Doco reference: List Indicators API | Microsoft Learn
Code block of Fields
{
name: 'arguments',
default: {},
description: "The request's query parameters",
displayName: 'Query Parameters',
displayOptions: {
show: {
resource: ['indicator'],
operation: ['getall'],
},
},
options: [
{
name: 'keyvalue',
displayName: 'Key:Value',
values: [
{
displayName: 'Key',
name: 'key',
type: 'string',
default: '',
required: true,
description: 'Key of query parameter',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
routing: {
send: {
property: '={{$parent.key}}',
type: 'query',
},
},
required: true,
description: 'Value of query parameter',
},
],
},
],
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
},