Spin-01004 no suitable data format detected at random time

Hi!
I am experiencing this problem, at random times an incident appears in some processes. I use Service-task with http-connector type for parsing JSON’s and calling a remote api to send the resulting JSON’s using POST method to the required service.

I have configured asynchronous operation and can see every step of the process in cocpit. At the step where the incident occurs, I have the fill variables stored that were obtained in previous Service Tasks, which, as I indicated above, are used in the final Service Task for parsing. I collected the data from these variables and tried to parse them locally and there were no errors there. I tried to send the received response myself via api call to the service using POST method and the same way, I didn’t get any errors. The status code was 200.

What can cause the error spin-01004 no suitable data format detected at random time, if the data in the variables are correct?

Here is an example of the process:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_14pvr29" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.16.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
  <bpmn:process id="ES_lukoil_Condition_of_pressurized_equipment_and_condition_of_dynamic_equipment_18" name="ES_lukoil_Condition_of_pressurized_equipment_and_condition_of_dynamic_equipment_18" isExecutable="true">
    <bpmn:startEvent id="start_process" name="Старт процесса">
      <bpmn:outgoing>Flow_1o3j15t</bpmn:outgoing>
      <bpmn:timerEventDefinition id="TimerEventDefinition_1clecix">
        <bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0  0 1,3,5,7,9,11,13,15,17,19,21,23 ? * *</bpmn:timeCycle>
      </bpmn:timerEventDefinition>
    </bpmn:startEvent>
    <bpmn:serviceTask id="get_data_shifts_object" name="Получить данные смен по объекту" camunda:asyncBefore="true">
      <bpmn:extensionElements>
        <camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="method">GET</camunda:inputParameter>
            <camunda:inputParameter name="headers">
              <camunda:map>
                <camunda:entry key="accept">text/plain</camunda:entry>
                <camunda:entry key="Platform-Authorization">${token.prop("token").stringValue()}</camunda:entry>
              </camunda:map>
            </camunda:inputParameter>
            <camunda:inputParameter name="url" />
            <camunda:outputParameter name="status_code">
              <camunda:script scriptFormat="JavaScript">statusCode;</camunda:script>
            </camunda:outputParameter>
            <camunda:outputParameter name="get_response">
              <camunda:script scriptFormat="JavaScript">S(response);</camunda:script>
            </camunda:outputParameter>
          </camunda:inputOutput>
          <camunda:connectorId>http-connector</camunda:connectorId>
        </camunda:connector>
        <camunda:inputOutput>
          <camunda:inputParameter name="productionFacilityIds">d7199a66-c43b-4552-9581-e9e3370814c8</camunda:inputParameter>
          <camunda:inputParameter name="firstCurrentShift">true</camunda:inputParameter>
          <camunda:inputParameter name="pageNum">1</camunda:inputParameter>
          <camunda:inputParameter name="pageSize">1</camunda:inputParameter>
          <camunda:outputParameter name="members_output">${get_response.elements().get(0).prop("members")}</camunda:outputParameter>
          <camunda:outputParameter name="getFromTime">${dateTime().minusMinutes(30).toString()}</camunda:outputParameter>
          <camunda:outputParameter name="getToTime">${dateTime().plusMinutes(30).toString()}</camunda:outputParameter>
          <camunda:outputParameter name="getResponseLength">${get_response}</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_15cmizx</bpmn:incoming>
      <bpmn:outgoing>Flow_0e3fmmj</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="end_process" name="Конец процесса">
      <bpmn:incoming>Flow_1vwori5</bpmn:incoming>
      <bpmn:incoming>Flow_0hf9v3r</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:serviceTask id="get_token" name="Получить token" camunda:asyncBefore="true">
      <bpmn:extensionElements>
        <camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="method">POST</camunda:inputParameter>
            <camunda:inputParameter name="headers">
              <camunda:map>
                <camunda:entry key="content-type">application/json</camunda:entry>
                <camunda:entry key="accept">text/plain</camunda:entry>
              </camunda:map>
            </camunda:inputParameter>
            <camunda:inputParameter name="url" />
            <camunda:inputParameter name="payload">{"username": "${username}", "password": "${password}"}</camunda:inputParameter>
            <camunda:outputParameter name="token">
              <camunda:script scriptFormat="JavaScript">S(response);</camunda:script>
            </camunda:outputParameter>
          </camunda:inputOutput>
          <camunda:connectorId>http-connector</camunda:connectorId>
        </camunda:connector>
        <camunda:inputOutput>
          <camunda:inputParameter name="username">OtchetESJ</camunda:inputParameter>
          <camunda:inputParameter name="password">secret</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_1o3j15t</bpmn:incoming>
      <bpmn:outgoing>Flow_15cmizx</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="post_data" name="Записать данные" camunda:asyncBefore="true">
      <bpmn:extensionElements>
        <camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="method">POST</camunda:inputParameter>
            <camunda:inputParameter name="headers">
              <camunda:map>
                <camunda:entry key="Content-Type">application/json</camunda:entry>
                <camunda:entry key="accept">text/plain</camunda:entry>
                <camunda:entry key="Platform-Authorization">${token.prop("token").stringValue()}</camunda:entry>
              </camunda:map>
            </camunda:inputParameter>
            <camunda:inputParameter name="url" />
            <camunda:inputParameter name="payload">
              <camunda:script scriptFormat="JavaScript">var membersOutputJson = JSON.parse(execution.getVariable('members_output'));

// Здесь можем выполнять операции с полученным JSON, например, фильтровать данные или извлекать значения

// Пример: Получение данных о пользователе с isChief = true
var chiefUser = membersOutputJson.find(function(user) {
  return user.isChief === true;
});

// Вычисление значения для eventDateTime
var currentDateTime = new Date().toISOString();

// Вычисление значения для deadline
var deadlineDateTime = new Date();
deadlineDateTime.setHours(deadlineDateTime.getHours() + 2);
var deadline = deadlineDateTime.toISOString();

// Формирование данных запроса в Swagger
var requestData = {
  "responsibleOperatorId": chiefUser.employeeId,
  "eventDateTime": currentDateTime,
  "status": {
    "id": 3001
  },
  "deadline": deadline,
  "priority": {
    "id": 2003
  },
  "category": {
    "id": "df6304d0-07a2-5271-9143-52719c41ef50",
    "code": 1121
},
"subCategory": {
    "parentCategoryId": "df6304d0-07a2-5271-9143-52719c41ef50",
    "id": "ec288af3-59b1-4202-9e86-3a9ad6b5d059",
    "code": 2262
},
  "description": "Записи по состоянию технологических трубопроводов и оборудования работающего под давлением (каждые 2 часа)",
  "isAcknowledged": false,
  "assignToShift": false,
  "facilityId": "d7199a66-c43b-4552-9581-e9e3370814c8",
  "isRestrictions": false,
  "facts": [
    {
      "comment": "Произведён наружный осмотр технологических трубопроводов, трубопроводов пара и горячей воды, сосудов, работающих под давлением и вакуумом , резервуаров, змеевиков печей - замечаний нет",
      "attachedFiles":[]
    }
  ]
};

JSON.stringify(requestData);</camunda:script>
            </camunda:inputParameter>
            <camunda:outputParameter name="post_response">
              <camunda:script scriptFormat="JavaScript">S(response);</camunda:script>
            </camunda:outputParameter>
          </camunda:inputOutput>
          <camunda:connectorId>http-connector</camunda:connectorId>
        </camunda:connector>
        <camunda:inputOutput>
          <camunda:inputParameter name="post_tag_id">192825100</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>false</bpmn:incoming>
      <bpmn:outgoing>Flow_1vwori5</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_1o3j15t" sourceRef="start_process" targetRef="get_token" />
    <bpmn:sequenceFlow id="Flow_15cmizx" sourceRef="get_token" targetRef="get_data_shifts_object" />
    <bpmn:sequenceFlow id="Flow_0e3fmmj" sourceRef="get_data_shifts_object" targetRef="Activity_1an8ycy" />
    <bpmn:sequenceFlow id="Flow_1vwori5" sourceRef="post_data" targetRef="end_process" />
    <bpmn:scriptTask id="Activity_1an8ycy" name="Проверка" camunda:asyncBefore="true" scriptFormat="JavaScript" camunda:resultVariable="result">
      <bpmn:incoming>Flow_0e3fmmj</bpmn:incoming>
      <bpmn:outgoing>Flow_0631es7</bpmn:outgoing>
      <bpmn:script>var membersOutputJson = JSON.parse(execution.getVariable('members_output'));
var keysArray = Object.keys(membersOutputJson);
var count_elem = keysArray.length;
var result = 0;
for (var i = 0; i &lt; count_elem ; i++ ){


        if (membersOutputJson[i].isResponsibleEvents === true){
             result = result + 1;}

       }
if (result &gt;= 1){
result = 1;
}


        result;</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="Flow_0631es7" sourceRef="Activity_1an8ycy" targetRef="Gateway_1q0btt7" />
    <bpmn:exclusiveGateway id="Gateway_1q0btt7" name="true_or_false">
      <bpmn:incoming>Flow_0631es7</bpmn:incoming>
      <bpmn:outgoing>false</bpmn:outgoing>
      <bpmn:outgoing>true</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="false" name="false" sourceRef="Gateway_1q0btt7" targetRef="post_data">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${result== '0'}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:serviceTask id="Activity_1ryql24" name="Записать данные" camunda:asyncBefore="true">
      <bpmn:extensionElements>
        <camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="method">POST</camunda:inputParameter>
            <camunda:inputParameter name="headers">
              <camunda:map>
                <camunda:entry key="Content-Type">application/json</camunda:entry>
                <camunda:entry key="accept">text/plain</camunda:entry>
                <camunda:entry key="Platform-Authorization">${token.prop("token").stringValue()}</camunda:entry>
              </camunda:map>
            </camunda:inputParameter>
            <camunda:inputParameter name="url" />
            <camunda:inputParameter name="payload">
              <camunda:script scriptFormat="JavaScript">var membersOutputJson = JSON.parse(execution.getVariable('members_output'));

// Здесь можем выполнять операции с полученным JSON, например, фильтровать данные или извлекать значения

// Пример: Получение данных о пользователе с isResponsibleEvents = true
var ResponsibleEvents = membersOutputJson.find(function(user) {
  return user.isResponsibleEvents === true;
});

// Вычисление значения для eventDateTime
var currentDateTime = new Date().toISOString();

// Вычисление значения для deadline
var deadlineDateTime = new Date();
deadlineDateTime.setHours(deadlineDateTime.getHours() + 2);
var deadline = deadlineDateTime.toISOString();

// Формирование данных запроса в Swagger
var requestData = {
  "responsibleOperatorId": ResponsibleEvents.employeeId,
  "eventDateTime": currentDateTime,
  "status": {
    "id": 3001
  },
  "deadline": deadline,
  "priority": {
    "id": 2003
  },
  "category": {
    "id": "df6304d0-07a2-5271-9143-52719c41ef50",
    "code": 1121
},
"subCategory": {
    "parentCategoryId": "df6304d0-07a2-5271-9143-52719c41ef50",
    "id": "ec288af3-59b1-4202-9e86-3a9ad6b5d059",
    "code": 2262
},
  "description": "Записи по состоянию технологических трубопроводов и оборудования работающего под давлением (каждые 2 часа)",
  "isAcknowledged": false,
  "assignToShift": false,
  "facilityId": "d7199a66-c43b-4552-9581-e9e3370814c8",
  "isRestrictions": false,
  "facts": [
    {
      "comment": "Произведён наружный осмотр технологических трубопроводов, трубопроводов пара и горячей воды, сосудов, работающих под давлением и вакуумом , резервуаров, змеевиков печей - замечаний нет",
      "attachedFiles":[]
    }
  ]
};

JSON.stringify(requestData);</camunda:script>
            </camunda:inputParameter>
            <camunda:outputParameter name="post_response">
              <camunda:script scriptFormat="JavaScript">S(response);</camunda:script>
            </camunda:outputParameter>
          </camunda:inputOutput>
          <camunda:connectorId>http-connector</camunda:connectorId>
        </camunda:connector>
        <camunda:inputOutput>
          <camunda:inputParameter name="post_tag_id">192825100</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>true</bpmn:incoming>
      <bpmn:outgoing>Flow_0hf9v3r</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="true" name="true" sourceRef="Gateway_1q0btt7" targetRef="Activity_1ryql24">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${result== '1'}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_0hf9v3r" sourceRef="Activity_1ryql24" targetRef="end_process" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ES_lukoil_Condition_of_pressurized_equipment_and_condition_of_dynamic_equipment_18">
      <bpmndi:BPMNShape id="Event_1u6qosz_di" bpmnElement="start_process">
        <dc:Bounds x="172" y="262" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="152" y="305" width="81" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1k916it_di" bpmnElement="get_data_shifts_object">
        <dc:Bounds x="420" y="240" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0zy2dld_di" bpmnElement="end_process">
        <dc:Bounds x="1252" y="262" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1160" y="273" width="82" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_0w78mzf" bpmnElement="get_token">
        <dc:Bounds x="270" y="240" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_079n6rr" bpmnElement="post_data">
        <dc:Bounds x="960" y="400" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_004bv18" bpmnElement="Activity_1an8ycy">
        <dc:Bounds x="570" y="240" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_1520cb8" bpmnElement="Gateway_1q0btt7" isMarkerVisible="true">
        <dc:Bounds x="725" y="255" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="785" y="273" width="64" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_01kc2nw" bpmnElement="Activity_1ryql24">
        <dc:Bounds x="960" y="80" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1o3j15t_di" bpmnElement="Flow_1o3j15t">
        <di:waypoint x="208" y="280" />
        <di:waypoint x="270" y="280" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_15cmizx_di" bpmnElement="Flow_15cmizx">
        <di:waypoint x="370" y="280" />
        <di:waypoint x="420" y="280" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0e3fmmj_di" bpmnElement="Flow_0e3fmmj">
        <di:waypoint x="520" y="280" />
        <di:waypoint x="570" y="280" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1vwori5_di" bpmnElement="Flow_1vwori5">
        <di:waypoint x="1060" y="440" />
        <di:waypoint x="1270" y="440" />
        <di:waypoint x="1270" y="298" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0631es7_di" bpmnElement="Flow_0631es7">
        <di:waypoint x="670" y="280" />
        <di:waypoint x="725" y="280" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1dyjc3x_di" bpmnElement="false">
        <di:waypoint x="750" y="305" />
        <di:waypoint x="750" y="440" />
        <di:waypoint x="960" y="440" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="754" y="370" width="23" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_15prjt2_di" bpmnElement="true">
        <di:waypoint x="750" y="255" />
        <di:waypoint x="750" y="120" />
        <di:waypoint x="960" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="756" y="185" width="18" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0hf9v3r_di" bpmnElement="Flow_0hf9v3r">
        <di:waypoint x="1060" y="120" />
        <di:waypoint x="1270" y="120" />
        <di:waypoint x="1270" y="262" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Here is the code that is used in the Service Task:

var membersOutputJson = JSON.parse(execution.getVariable('members_output'));

// Здесь можем выполнять операции с полученным JSON, например, фильтровать данные или извлекать значения

// Пример: Получение данных о пользователе с isResponsibleEvents = true
var ResponsibleEvents = membersOutputJson.find(function(user) {
  return user.isResponsibleEvents === true;
});

// Вычисление значения для eventDateTime
var currentDateTime = new Date().toISOString();

// Вычисление значения для deadline
var deadlineDateTime = new Date();
deadlineDateTime.setHours(deadlineDateTime.getHours() + 2);
var deadline = deadlineDateTime.toISOString();

// Формирование данных запроса в Swagger
var requestData = {
  "responsibleOperatorId": ResponsibleEvents.employeeId,
  "eventDateTime": currentDateTime,
  "status": {
    "id": 3001
  },
  "deadline": deadline,
  "priority": {
    "id": 2003
  },
  "category": {
    "id": "df6304d0-07a2-5271-9143-52719c41ef50",
    "code": 1121
},
"subCategory": {
    "parentCategoryId": "df6304d0-07a2-5271-9143-52719c41ef50",
    "id": "ec288af3-59b1-4202-9e86-3a9ad6b5d059",
    "code": 2262
},
  "description": "Записи по состоянию технологических трубопроводов и оборудования работающего под давлением (каждые 2 часа)",
  "isAcknowledged": false,
  "assignToShift": false,
  "facilityId": "d7199a66-c43b-4552-9581-e9e3370814c8",
  "isRestrictions": false,
  "facts": [
    {
      "comment": "Произведён наружный осмотр технологических трубопроводов, трубопроводов пара и горячей воды, сосудов, работающих под давлением и вакуумом , резервуаров, змеевиков печей - замечаний нет",
      "attachedFiles":[]
    }
  ]
};

JSON.stringify(requestData);

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