n8n icon indicating copy to clipboard operation
n8n copied to clipboard

API call errors - tags and workflow execution

Open salacoste opened this issue 1 year ago • 3 comments

Bug Description

1. Tag Update Conflict (409)

Endpoint: PUT /api/v1/tags/{id}

Request:

// Update existing tag with the same name
await axios.put(
  'https://n8n-instance.com/api/v1/tags/12345',
  { name: "Existing Tag Name" },
  { headers: { 'X-N8N-API-KEY': 'api_key_here' } }
);

Actual Response:

Status: 409

  "code": 409,
  "message": "Tag with this name already exists"
}

Expected: Status 200 OK with updated tag data

  1. Workflow Activation Without Valid Trigger (400) Endpoint: POST /api/v1/workflows/{id}/activate Request:
// Create workflow with manualTrigger
const workflow = {
  name: "Test Workflow",
  nodes: [
    {
      "id": "node_1",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "parameters": {},
      "position": [100, 300]
    },
    // Other nodes...
  ],
  "connections": {
    // Connections...
  }
};

// Create then activate
const createResponse = await axios.post(
  'https://n8n-instance.com/api/v1/workflows',
  workflow,
  { headers: { 'X-N8N-API-KEY': 'api_key_here' } }
);

await axios.post(
  `https://n8n-instance.com/api/v1/workflows/${createResponse.data.id}/activate`,
  {},
  { headers: { 'X-N8N-API-KEY': 'api_key_here' } }
);

Actual Response:

Status: 400
{
  "code": 400,
  "message": "Workflow has no node to start the workflow - at least one trigger, poller or webhook node is required"
}
  1. Execution Failures for Webhook and Manual Triggers Endpoint: POST /api/v1/workflows/{id}/run Request:
// Execute workflow with webhook or manual trigger
await axios.post(
  'https://n8n-instance.com/api/v1/workflows/12345/run',
  {},
  { headers: { 'X-N8N-API-KEY': 'api_key_here' } }
);

Actual Response (webhook):

Status: 404
{
  "code": 404,
  "message": "Not Found"
}

Response:

Status: 404
{
  "code": 404,
  "message": "Not Found"
}

Actual Response (manualTrigger): No error, but execution does not properly activate the trigger Expected: Status 200 OK with successful execution for all trigger types

n8n Version Information API Version: 1.82.3

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

To Reproduce

execute api calls

await axios.put( 'https://n8n-instance.com/api/v1/tags/12345', { name: "Existing Tag Name" }, { headers: { 'X-N8N-API-KEY': 'api_key_here' } } );

const workflow = { name: "Test Workflow", nodes: [ { "id": "node_1", "name": "Manual Trigger", "type": "n8n-nodes-base.manualTrigger", "parameters": {}, "position": [100, 300] }, // Other nodes... ], "connections": { // Connections... } };

// Create then activate const createResponse = await axios.post( 'https://n8n-instance.com/api/v1/workflows', workflow, { headers: { 'X-N8N-API-KEY': 'api_key_here' } } );

await axios.post( https://n8n-instance.com/api/v1/workflows/${createResponse.data.id}/activate, {}, { headers: { 'X-N8N-API-KEY': 'api_key_here' } } );

Expected behavior

Expected: Status 200 OK with successful execution for all trigger types

Operating System

Ubuntu

n8n Version

1.83.2

Node.js Version

20.18

Database

MySQL

Execution mode

main (default)

salacoste avatar Mar 17 '25 17:03 salacoste

Hey @salacoste,

We have created an internal ticket to look into this which we will be tracking as "GHC-1248"

Joffcom avatar Mar 17 '25 17:03 Joffcom

appreciate it so much, i have been doing the MCP workflow server for n8n and found these uncertainties compared to the one that the docs say. Possibly I'm wrong but when I missed or misinterpreted the docs and request structure, let me know.

salacoste avatar Mar 18 '25 13:03 salacoste

Hey @salacoste,

I've just tried to update tags and I have no problem using Insomnia (HTTP client) on my local environment:

Tag Update

GET request to get all tags before:

http://localhost:5678/api/v1/tags

Image

PUT request to update the tag:

http://localhost:5678/api/v1/tags/WF2RfTaYnoQbhrRX

{
	"name": "newTagName"
}

Image

200 response

GET request to get all tags after with the tag updated:

http://localhost:5678/api/v1/tags

Image

You should be able to update the tag name repeatedly to the same name and still get a 200. Unless there's a DB error, I don't think you would receive a 409:

https://github.com/n8n-io/n8n/blob/61957899e1ca9c013dbd0c3385f9484d724df3a0/packages/cli/src/public-api/v1/handlers/tags/tags.handler.ts#L44-L49

Can you give me any more details for recreating this?

Workflow activation

If you don't have a valid trigger that can be executed, you'd expect to get a 400 response. In my example I have a manual trigger so it can't be activated. Image

400 response

{
	"message": "Workflow \"My workflow 2\" (ID: 100Vv1Q5w6latF5K) has no node to start the workflow - at least one trigger, poller or webhook node is required"
}

If you change it to a scheduled trigger like this, then you'll get a 200 response:

Image

{
	"createdAt": "2025-04-08T12:49:38.542Z",
	"updatedAt": "2025-04-10T15:30:05.000Z",
	"id": "100Vv1Q5w6latF5K",
	"name": "My workflow 2",
	"active": true,
	"nodes": [
		{
			"parameters": {
				"assignments": {
					"assignments": [
						{
							"id": "3a40d9f2-0eed-4a92-9287-9d6ec9ce90e8",
							"name": "message",
							"value": "hello there",
							"type": "string"
						}
					]
				},
				"options": {}
			},
			"type": "n8n-nodes-base.set",
			"typeVersion": 3.4,
			"position": [
				220,
				0
			],
			"id": "1fcb0721-0fc7-44df-8930-626afa77c1c6",
			"name": "Edit Fields1"
		},
...

Running a workflow

I don't think we expose the /workflows/:workflowId/run endpoint via the public API. This will be why you're getting a 404.

https://github.com/n8n-io/n8n/blob/c89010871d28e2cc4d5807fb7b3aa29968a0364c/packages/cli/src/public-api/v1/handlers/workflows/spec/paths/workflows.id.yml

MarcL avatar Apr 10 '25 15:04 MarcL

Hi @salacoste

We haven’t heard back for a while so we’re going to close this for now.

If you’re still running into the issue, or have more details to share, feel free to reopen it or create a new one.

Thanks!

MarcL avatar Apr 23 '25 09:04 MarcL