How to access webhook query parameters

Hi,

I’m trying to process the query data in the code node but unsure what’s the correct syntax. My postman request to the webhook contains a query of ?OBID=123123123&CombineRels=Classification_21,DocumentRevisions_12

Since the actual application don’t support payload so I’m working around by generating the payload body array based on the number of comma for the query parameter CombineRels, in order to use ItemLists node.

I could use $json.query.OBID when the mode is Run Once for Each Item, but not when it is Run Once for All Items. I tried both query.CombineRels, query[0].CombineRels, $json.query.CombineRels but none working.

Anyone can point me to the right direction? Thanks.

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

Hi @engowen, you can access incoming data in the Code through the methods and variables listed on Built in methods and variables reference - n8n Documentation. Make sure you also take a look at the example code provided by n8n when adding a new code, this would differ slightly depending on whether you are using the “Run Once for All Items” mode vs. the “Run Once for Each Item” mode.

Assuming you want to convert your “CombineRels” data into an array, you could do something like this:

This would add a new rels field to your item:

Hope this helps! If you’re looking for a different result, perhaps you can share an example of what you would like to see?

2 Likes

Thanks @MutedJam for the pointer!

1 Like

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