المقسم 2: أنماط المصادقة والتكامل للواجهات البرمجية - تمرين عملي لنظام معالجة الطلبات عبر webhook

صِف المشكلة/الخطأ/السؤال

✓ طلب صحيح يعيد 200 برد صحيح
✗ الحقول الناقصة تعيد 400 برسالة خطأ. متوقع خطأ 400 للحقول المفقودة المطلوبة
✓ المصادقة الناقصة تعيد 403

فشلت في اجتياز اختبار webhook، اتبعت التعليمات 100% لكن فشلت مع ذلك.

ما هي رسالة الخطأ (إن وجدت)؟

**✓**طلب صحيح يعيد 200 برد صحيح

**✗**الحقول الناقصة تعيد 400 برسالة خطأ. متوقع خطأ 400 للحقول المفقودة المطلوبة

**✓**المصادقة الناقصة تعيد 403

يرجى مشاركة سير العمل الخاص بك

(حدِّد العقد على لوحتك واستخدم اختصارات لوحة المفاتيح CMD+C/CTRL+C و CMD+V/CTRL+V لنسخ ولصق سير العمل.)
{
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "course/n8n102/new-order",
        "authentication": "headerAuth",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "e562e52c-483b-4084-a08b-96a9ff6bf1a9",
      "name": "WebhookNewOrder",
      "webhookId": "01db53d7-73ec-40c2-b91b-2c97da6e2535",
      "credentials": {
        "httpHeaderAuth": {
          "id": "IZ1z1MYLBwpoKx2J",
          "name": "n8n Academy API Key"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "a65d16fa-2ec8-48ee-898e-a0ef28462992",
              "leftValue": "={{ $json.body.order_id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            },
            {
              "id": "3c8039b7-3a17-4387-805c-59ea5ff40377",
              "leftValue": "={{ $json.body.customer_id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            },
            {
              "id": "19ef2054-2b99-4b20-9a17-e4f900b9d050",
              "leftValue": "={{ $json.body.total }}",
              "rightValue": "",
              "operator": {
                "type": "number",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        208,
        0
      ],
      "id": "14611c3e-1eb2-4802-8fbc-2309d1a7074e",
      "name": "ValidateRequiredFields"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"status\": \"accepted\",\n  \"order_id\": \"{{ $('WebhookNewOrder').item.json.body.order_id }}\",\n  \"message\": \"Order received and queued for processing\"\n}",
        "options": {
          "responseCode": 200
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        416,
        -96
      ],
      "id": "d1fd5364-556a-46d4-9240-fb84f22e9767",
      "name": "RespondSuccess"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"status\": \"error\",\n  \"message\": \"Missing required fields: order_id, customer_id, and total are required\"\n}",
        "options": {
          "responseCode": 400
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        416,
        96
      ],
      "id": "c7dad4f2-1f70-4138-914c-144de8643f7e",
      "name": "RespondValidationError"
    }
  ],
  "connections": {
    "WebhookNewOrder": {
      "main": [
        [
          {
            "node": "ValidateRequiredFields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ValidateRequiredFields": {
      "main": [
        [
          {
            "node": "RespondSuccess",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "RespondValidationError",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "bed2988fb684ee16b2cfbdee45dcd5e341307ecfd375cd84c432f4ed9cece2d3"
  }
}

شارك المخرجات التي أعادتها العقدة الأخيرة

معلومات عن إعداد n8n الخاص بك

    1. إصدار n8n: 2.15.0
    2. قاعدة البيانات: SQLite (افتراضي)
    3. إعداد EXECUTIONS_PROCESS: main
    4. تشغيل n8n عبر: Docker (على Zeabur)
    5. نظام التشغيل: Linux (Ubuntu 24، مستضاف على Zeabur)

هذا شرط عدم توافق النوع

غيرت إلى string … أيضاً لا يمكن حل … لست متأكداً ما المشكلة عدم توافق.. .بالفعل اتبعت التعليمات المعطاة

مرحبا،

كان لدينا خطأ تم حله.

تحياتي،