When working on a project, I extract JSON objects from the Zammad-API.
One of the tickets retrieved is as follows:
[
{
"id": 53,
"group_id": 2,
"priority_id": 2,
"state_id": 2,
"organization_id": null,
"number": "740534",
"title": "Testanfrage Weichinger",
...
}
]
Additionally, there are ticket articles associated with this ticket:
[
{
"id": 130,
"ticket_id": 53,
"type_id": 1,
...
},
{
"id": 131,
"ticket_id": 53,
"type_id": 1,
...
}
]
A freelancer has provided a Node.js script that can be accessed via an HTTP request.
This code requires both JSON objects to be combined in one "body" like so:
{
"Ticket": {
"id": 53,
"group_id": 2,
"priority_id": 2,
"state_id": 2,
...
},
"articles": [
{
"id": 130,
"ticket_id": 53,
"type_id": 1,
...
},
{
"id": 131,
"ticket_id": 53,
"type_id": 1,
...
}
]
}
I need help writing a JavaScript code snippet for my n8n workflow to achieve this combination. I have tried searching for solutions on merging and concatenating JSON, but adding the necessary names like "Ticket:" and "articles:" complicates things for me as I am not familiar with JS coding. Any assistance would be greatly appreciated!