مشاكل مع Sendorders في تمرين دورة n8n Foundation

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

عند إرسال الطلب إلى موقع n8n، أحصل على الأخطاء أدناه. تحققت من المسافات والحسابات وما إلى ذلك، لكن لا يمكنني العثور على مصدر الخطأ. جميع عقدي تعمل بشكل مثالي عند تنفيذها بشكل فردي

ما هي رسالة الخطأ (إن وجدت)؟ طلبك غير صحيح أو لم يتمكن الخدمة من معالجته. إجماليات طلبك غير صحيحة. يرجى التأكد من حساب الإجماليات بشكل صحيح.

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

{
  "nodes": [
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6e58682d-4337-46a8-a36f-a6047502bfe7",
              "name": "order_id",
              "value": "={{ $json.order_id }}",
              "type": "string"
            },
            {
              "id": "2a009df0-7d77-43e6-9e91-a70e004bb17f",
              "name": "customer_name",
              "value": "={{ $json.customer_name }}",
              "type": "string"
            },
            {
              "id": "c36c31fc-c9a7-4dcb-8002-c7434369ea78",
              "name": "region",
              "value": "={{ $json.region }}",
              "type": "string"
            },
            {
              "id": "a6ad9769-cf53-4e2d-b27f-8869ec1506d3",
              "name": "status",
              "value": "={{ $json.status }}",
              "type": "string"
            },
            {
              "id": "ea21f188-1793-4fbc-80b4-14d080492695",
              "name": "order_total",
              "value": "={{Math.round($json.quantity * $json.unit_price)}}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        16,
        -112
      ],
      "id": "e5206f2a-e49f-4f97-a253-f42bbdee3f20",
      "name": "SetOrderTotals"
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "orders",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        608,
        -320
      ],
      "id": "f4a9b2b7-cbb5-4092-adae-82a31b6faadf",
      "name": "AggregateOrders"
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "C0BEZ3AKS9E",
          "mode": "list",
          "cachedResultName": "test"
        },
        "text": "=\"تم إكمال خط أنابيب المبيعات. تمت معالجة 50 طلبًا، وتم تسليم 38.\"\n\"إجمالي الطلبات الشمالي:\" {{ $json.region[0].average_order_total }}\n\"إجمالي الطلبات الجنوبي:\" {{ $json.region[2].average_order_total }}\n\"إجمالي الطلبات الغربي:\" {{ $json.region[1].average_order_total }}\n\"إجمالي الطلبات الشرقي:\" {{ $json.region[3].average_order_total }}",
        "otherOptions": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.5,
      "position": [
        816,
        -416
      ],
      "id": "27fbb4f2-ab2a-4977-bef1-5350b8a52c03",
      "name": "SendToSlack",
      "webhookId": "5a4cba28-edf6-40b0-b14f-d68952cccf47",
      "credentials": {
        "slackApi": {
          "id": "JsMFdrKSTabhvlb7",
          "name": "حساب Slack"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://learn.app.n8n.cloud/webhook/course/n8n101/process-orders",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-assessment-id",
              "value": "dcaececa5196aa91d2a41fc5b5b53ec8"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "orders",
              "value": "={{ $json.orders }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        816,
        -224
      ],
      "id": "2a053049-1a4b-46f0-abf1-3787c72a1297",
      "name": "SendOrders",
      "credentials": {
        "httpHeaderAuth": {
          "id": "Ga9QOladMz18EL6I",
          "name": "مفتاح واجهة برمجة التطبيقات لأكاديمية n8n"
        }
      }
    },
    {
      "parameters": {
        "fieldsToSummarize": {
          "values": [
            {
              "aggregation": "sum",
              "field": "order_total"
            },
            {
              "field": "order_total"
            },
            {
              "aggregation": "average",
              "field": "order_total"
            }
          ]
        },
        "fieldsToSplitBy": "region",
        "options": {}
      },
      "type": "n8n-nodes-base.summarize",
      "typeVersion": 1.1,
      "position": [
        208,
        -320
      ],
      "id": "91cd6ef5-16d0-4ea0-89a6-b5d2499b1681",
      "name": "SummarizebyRegion"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c271aab4-45e9-4cd8-bc1e-5fee1682718a",
              "name": "sum_order_total",
              "value": "={{ Math.round($json.sum_order_total *100)/100}}",
              "type": "number"
            },
            {
              "id": "8a43ca44-257c-4d5e-9240-396005282a88",
              "name": "count_order_total",
              "value": "={{ $json.count_order_total }}",
              "type": "number"
            },
            {
              "id": "4e9f85c6-ec6e-4a80-bd09-024fadd61c5f",
              "name": "average_order_total",
              "value": "={{ Math.round($json.average_order_total*100)/100 }}",
              "type": "number"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        416,
        -320
      ],
      "id": "ea9206a9-c0e7-4836-9194-9a07c0826961",
      "name": "Edit Fields"
    }
  ],
  "connections": {
    "SetOrderTotals": {
      "main": [
        [
          {
            "node": "SummarizebyRegion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AggregateOrders": {
      "main": [
        [
          {
            "node": "SendToSlack",
            "type": "main",
            "index": 0
          },
          {
            "node": "SendOrders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SummarizebyRegion": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AggregateOrders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "7134812ff1766ac00dec6d0b790eac6d9b713a9539f0e1c05a87cf2a2442a32d"
  }
}

طلبك غير صحيح أو لم تتمكن الخدمة من معالجته
إجماليات طلبك غير صحيحة. يرجى التأكد من حساب الإجماليات بشكل صحيح.


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

  • إصدار n8n: Community
  • قاعدة البيانات (الإعداد الافتراضي: SQLite):
  • إعداد n8n EXECUTIONS_PROCESS (الإعداد الافتراضي: own, main):
  • تشغيل n8n عبر (Docker, npm, n8n cloud, desktop app):
  • نظام التشغيل: Windows

مرحبا فينو،

الخطأ “Your order totals are incorrect” يشير دائمًا تقريبًا إلى مشكلة في صيغة حمولة JSON في عقدة SendOrders (HTTP Request) الخاصة بك.

عندما تستخدم ={{ $json.orders }} في حقل القيمة، غالبًا ما يقوم n8n بتمرير البيانات كسلسلة نصية، لكن نقطة نهاية n8n Academy API تتوقع بالتحديد كائن JSON يحتوي على مصفوفة الطلبات.

إليك كيفية إصلاحه:

  1. غيّر نوع محتوى الجسم: في عقدة SendOrders الخاصة بك، تأكد من تفعيل خيار Send Body، لكن ابحث عن خيار مثل “JSON” أو “Body Parameters” وتأكد من أنه لا يفرض البيانات في صيغة سلسلة نصية.

  2. استخدم محرر التعبيرات بشكل صحيح: في حقل Value لمعامل الجسم orders، حاول استخدام تعبير يفرض بنية كائن JSON: ={{ JSON.stringify($json.orders) }} أو، والأفضل من ذلك، إذا كانت العقدة تدعمها، غيّر نوع Body Parameters إلى JSON واستخدم {{ $json.orders }} مباشرة بدون علامات اقتباس.

  3. تحقق من عقدة SetOrderTotals الخاصة بك: أنت تستخدم Math.round($json.quantity * $json.unit_price). تحقق جيدًا من أن بيانات الإدخال الخاصة بك لا تحتوي على سلاسل نصية مخفية أو قيم فارغة. إذا كان يتم تفسير quantity أو unit_price كسلاسل نصية، فقد تفشل العملية الحسابية بصمت أو تنتج أنواعًا غير متوقعة. حاول تغليفها في Number(): ={{ Math.round(Number($json.quantity) * Number($json.unit_price)) }}

    لرؤية ما “يراه” API بالضبط، أضف عقدة Webhook أو استخدم خدمة مثل Webhook.site للتحقق من الحمولة الصادرة بالضبط من عقدة SendOrders الخاصة بك. إذا أرجع API خطأ 400، فهذا يعني بالتأكيد أنه استقبل سلسلة نصية بدلاً من مصفوفة JSON المتوقعة.

    أخبرني إذا كان هذا قد أوضح خطأ التحقق!

    تحياتي، Swapnil swapnilailabs.com

مرحباً Swapnil

شكراً لك على الرد السريع جداً. اسمح لي بشرح ما فعلته قبل نشري هذه المشكلة

  1. تحققت من جميع العقد للتأكد من أن نوع البيانات لإجمالي الطلب صحيح. تم تعيينه كأرقام
  2. في عقدة الإرسال،
    1. في body، نوع محتوى Body هو JSON
    2. حدد الحقول:
      الاسم: orders
    3.     القيمة: {{ $json.orders }}
      

جميع العقد يتم تنفيذها بشكل مثالي دون أي أخطاء.

جربت Webhook أيضاً وليس هناك أي أخطاء فيه.

فيما يلي نتيجة webhook

{“orders”:[{“sum_order_total”:5348,“count_order_total”:16,“average_order_total”:334.25,“region”:“north”},{“sum_order_total”:2507,“count_order_total”:10,“average_order_total”:250.7,“region”:“west”},{“sum_order_total”:2353,“count_order_total”:14,“average_order_total”:168.07,“region”:“south”},{“sum_order_total”:2263,“count_order_total”:10,“average_order_total”:226.3,“region”:“east”}]}

مرحباً @venu_nair ،

قد تحتاج إلى مقارنة سير عملك بالتعليمات مرة أخرى، حيث أرى أن الفرع أعلاه يحتوي على عدد من العقد أكثر من المرة السابقة التي قمت بها.

مرحبا بالجميع،

أواجه نفس الخطأ لنفس سير العمل المشترك في عنوان URL Course | n8n Platform

فيما يلي سير عملي ورسالة الخطأ.

أي مساعدة في اكتشاف المشكلة موضع تقدير كبير! :slight_smile:

سير العمل

كود سير العمل

Section 2 - Sales Data Pipeline.json (5.6 KB)

الخطأ الذي تم الحصول عليه في العقدة الأخيرة - SendOrders

{
“errorMessage”: “طلبك غير صحيح أو لم يتمكن الخدمة من معالجته”,
“errorDescription”: “إجماليات طلبك غير صحيحة. يرجى التأكد من أنك تحسب الإجماليات بشكل صحيح.”,
“errorDetails”: {
“rawErrorMessage”: [
“422 - "{\"error\":\"إجماليات طلبك غير صحيحة. يرجى التأكد من أنك تحسب الإجماليات بشكل صحيح.\"}"”
],
“httpCode”: “422”
},
“n8nDetails”: {
“nodeName”: “SendOrders”,
“nodeType”: “n8n-nodes-base.httpRequest”,
“nodeVersion”: 4.4,
“itemIndex”: 0,
“time”: “03/07/2026, 14:12:47”,
“n8nVersion”: “2.27.5 (Self Hosted)”,
“binaryDataMode”: “filesystem”,
“stackTrace”: [
“NodeApiError: طلبك غير صحيح أو لم تتمكن الخدمة من معالجته”,
" at ExecuteContext.execute (C:\Users\Jaideep Satghare\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-nodes-base\nodes\HttpRequest\V3\HttpRequestV3.node.ts:869:16)“,
" at WorkflowExecute.executeNode (C:\Users\Jaideep Satghare\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:1067:8)”,
" at WorkflowExecute.runNode (C:\Users\Jaideep Satghare\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:1367:11)“,
" at C:\Users\Jaideep Satghare\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:1829:27”,
" at C:\Users\Jaideep Satghare\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:2521:11"
]
}
}

مرحباً @Jaideep_Satghare، يرجى التحقق من إعدادات حقل “order_total” الخاص بعقدة “SetOrderTotals” وفقاً للتعليمات. أرى أنه مختلف.

كذلك، مشكلتك مختلفة قليلاً، لذا من الجدير فتح منشور آخر حتى يتمكن الآخرون من مساعدتك أيضاً، شكراً.

@kristinker ، شكراً على ردك. :smiley:

لقد قمت بتعديل حقل “order_total” عن قصد باستخدام دالة Math rounding لفرض تحويل العدد الصحيح.

ومع ذلك، تمكنت من العثور على المشكلة وهي مسافة زائدة في اسم الحقل لـ order_total. كنت أستخدم "order_total " بدلاً من “order_total”. لقد صححتها والآن تعمل بشكل جيد.

شكراً لطلبك مني إعادة النظر في العقدة. :smiley:

يمكن إغلاق هذه المشكلة من وجهة نظري. سأفتح مناقشة جديدة في المستقبل للمشاكل المماثلة.