GET request shows empty execution but data exists - need help

Hello everyone!!! Tell me, please. I run an hhtp get request every 30 seconds to check the task. It turns out to be infinite because execution is empty. Although there is data. Is there any way to fix this? Who solved this problem?

btw first run is Ok, but 2 and so on is 404


Hey @zzsnowballzz hope all is well, welcome to the community.

404 is an error, returned by the remote server, meaning that IF you are 100% sure that the url https://api.piapi.ai/api/v1/task/8c1e6cee-6810-45ef-899a-c11b4cedf969 is correct, then there must be something else api.piapi.ai doesn’t like which causes it to return 404 (most of the time. this means that the server wasn’t able to find something). I don’t believe there is much you can do from n8n side to fix this, there has to be an error somewhere - either with how you send the request or how the other side processes it.

Do you think you could embed your workflow here and hopefully pin some input data for the problematic node?

Thanks for the reply. I understand when a 404 error arrives. This is precisely because the second run does not put a value in the variable. The first time passes. But after the loop it is empty. Therefore 404

{
  "nodes": [
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a390f82e-050d-4ce1-b5ed-e409659530c1",
              "name": "video_url",
              "value": "={{ $json.data.output.video_url }}",
              "type": "string"
            },
            {
              "id": "b04a2620-c9ff-4b91-b729-bd19e3a8b4fb",
              "name": "prompt",
              "value": "={{ $json.data.input.prompt }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "55842add-a7fb-442e-b55b-161f319fe61c",
      "name": "Success",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -180,
        -20
      ]
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "prompt"
            },
            {
              "name": "image"
            },
            {
              "name": "chat_id",
              "type": "any"
            },
            {
              "name": "negative_prompt"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -2000,
        100
      ],
      "id": "a3f49e0a-3c2b-404f-8c54-5b2545b8412d",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d40992c1-52b4-466d-a32a-52d4fe59e256",
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -940,
        100
      ],
      "id": "3d426e44-cca3-4412-9772-cedff5f89cfa",
      "name": "If"
    },
    {
      "parameters": {
        "amount": 10
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -900,
        380
      ],
      "id": "39a16435-81cf-4f49-afb3-2bbbfe5925dc",
      "name": "Wait",
      "webhookId": "a63b3efa-19c2-44e3-9fe9-f2d8270410a9"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.piapi.ai/api/v1/task",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "piAPIApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"Qubico/flux1-dev-advanced\",\n  \"task_type\": \"controlnet-lora\",\n  \"input\": {\n    \"prompt\": \"{{ $json.prompt }}\",\n    \"control_net_settings\": [\n      {\n        \"control_type\": \"depth\",\n        \"control_image\": \"{{ $json.image }}\"\n      }\n    ],\n    \"lora_settings\": [\n      {\n        \"lora_type\": \"mjv6\"\n      }\n    ]\n  }\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1560,
        100
      ],
      "id": "bdffc96d-1894-464a-b317-02d7aa66a0be",
      "name": "HTTP Request",
      "credentials": {
        "piAPIApi": {
          "id": "gnj5RA5FAG1mMMMz",
          "name": "PiAPI account 2"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendChatAction",
        "chatId": "={{ $('When Executed by Another Workflow').item.json.chat_id }}",
        "action": "upload_photo"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -680,
        380
      ],
      "id": "5b80ba2f-487c-4ebe-8b1a-80fadf3f6e15",
      "name": "Send a chat action",
      "webhookId": "fd7d63f4-a598-4fd1-a0de-db569741e2b9",
      "credentials": {
        "telegramApi": {
          "id": "kdoeziWXfYXRl9KA",
          "name": "123"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1120,
        100
      ],
      "id": "88e6a33a-75ac-4b22-b8b0-13c6e94d0071",
      "name": "Trouble here",
      "credentials": {
        "httpHeaderAuth": {
          "id": "1VpAhv6ElaosRkbc",
          "name": "Goapi"
        }
      },
      "onError": "continueRegularOutput"
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Send a chat action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Trouble here",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a chat action": {
      "main": [
        [
          {
            "node": "Trouble here",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trouble here": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "e24f19d897fbcfb06d96c9173e7c8dc910053690edc62df56555ef40299436c1"
  }
}```

In general, I got out of the situation differently. I’m catching a ready-made task on a webhook. But I still wonder why the variable becomes empty in the loop.

I guess you are doing something like this and didn’t get the correct task_id after 2nd execution. Can you show the full workflow?

1 Like

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