0

我想将一个 REST API 的输出传递给 camunda 中的另一个 REST-API。我的第一个 API 返回 JSON,它的值为 email 。我正在使用 HTTP-CONNECTOR 脚本变量从第一个 REST-API 获取输出

<camunda:outputParameter name="email">
              <camunda:script scriptFormat="JavaScript">var value = S(NUMBER, 'application/json');
print("DATA ::: "+ value);
var response = S(connector.getVariable("response"), 'application/json');
print("Response ::: "+ response );
print("Email :::"+ response.prop("email"));
response.prop("email");</camunda:script>
            </camunda:outputParameter>

现在我想在另一个我正在使用 HTTP-CONNECTOR 的 rest-API 调用的有效负载中传递电子邮件

<camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="url">http://localhost:8080/step2</camunda:inputParameter>
            <camunda:inputParameter name="method">POST</camunda:inputParameter>
            <camunda:inputParameter name="header">
              <camunda:map>
                <camunda:entry key="accept">application/json</camunda:entry>
                <camunda:entry key="content-type">application/json</camunda:entry>
              </camunda:map>
            </camunda:inputParameter>
            <camunda:inputParameter name="payload">
              <camunda:script scriptFormat="JavaScript">var email=execution.getVariable("email");</camunda:script>
            </camunda:inputParameter>
          </camunda:inputOutput>
          <camunda:connectorId>http-connector</camunda:connectorId>
        </camunda:connector>

但它给出了错误

wsmsDefaultHandlerExceptionResolver:已解决 [org.springframework.web.HttpMediaTypeNotSupportedException:不支持内容类型'']

如何将输出变量传递给下一个 REST-API?

4

1 回答 1

0

<camunda:inputParameter name="header">而不是<camunda:inputParameter name="headers">应该使用它,而且永远不可能将脚本作为输入传递给文本变量。所以我用

<camunda:outputParameter name="email">
             ${response}
</camunda:outputParameter>

将完整的响应传递给下一个服务

于 2019-03-08T09:14:30.753 回答