You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启动Camunda流程遇SPIN-01004错误:无匹配数据格式检测到

Fixing SPIN-01004 Error When Parsing JSON Response in Camunda Service Task

Alright, let's tackle that SPIN-01004 error you're hitting. The root issue here is that Camunda's SPIN API isn't recognizing your service task's response as a valid JSON format—even though it looks like JSON, it's actually being treated as a plain string right now.

Let's break down what's going wrong and how to fix it:

Why You're Seeing the Error

Your service task returns an escaped JSON string: "{\"key\":\"value\"}". When you pass this directly to S(response), SPIN doesn't auto-detect it as JSON because it's wrapped in quotes (it's a string representation of JSON, not the parsed object itself). On top of that, your script is trying to access key1 but your actual JSON only has key—that's a mismatch that would cause another error even after fixing the format issue.

Step-by-Step Fix

Update your output parameter script to first parse the string into a proper JSON object, then access the correct key:

Option 1: Use SPIN's Built-in JSON Parsing

This leverages Camunda's SPIN API to convert the string to a JSON object before accessing properties:

<camunda:outputParameter name="Result">
  <camunda:script scriptFormat="Javascript">
    // Parse the string to JSON, then get the "key" property
    S(response).json().prop('key').value();
  </camunda:script>
</camunda:outputParameter>

Option 2: Use Native JavaScript JSON.parse

If you prefer plain JS, this works too:

<camunda:outputParameter name="Result">
  <camunda:script scriptFormat="Javascript">
    // Parse the string and directly access the "key" property
    JSON.parse(response).key;
  </camunda:script>
</camunda:outputParameter>

Quick Checks to Avoid Future Issues

  • Double-check your JSON keys: Make sure the property name in your script (key) matches exactly what's in the response—JSON is case-sensitive!
  • Validate your response: Ensure the service task is returning a valid JSON string (no typos, missing brackets, etc.). You can test it with a basic JSON validator if you're unsure.
  • Confirm SPIN is available: For older Camunda versions, ensure the SPIN module is deployed (most recent versions include it by default).

内容的提问来源于stack exchange,提问作者Albin Chandy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:27:25