Minrg
February 28, 2020, 6:37pm
1
Hello, I’m to trying retrieve the diagram XML via the [REST] API, like this:
I do get the data from Postman, but when I use it in Springboot:
var settings = {
"url": "http://10.168.5.22:8180/rest/process-definition/key/VentaNueva/xml",
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done(function(response) {
viewer.importXML(response, function(err) {
if (err) {
console.log(err);
} else {
console.log('Flujo Renderizado');
}
});
});
----------------------------------------------------------------------------------------------------------------
Im getting this:
Error: “required args <xml=string>”
js 6.1.2/dist/bpmn-modeler.development.js:6858
js 6.1.2/dist/bpmn-modeler.development.js:7083
js 6.1.2/dist/bpmn-modeler.development.js:8685
@Minrg when you get processdefinition xml, the api will return serialized bpmn xml string. If you are using spring boot then you can easily obtain a BpmnModelInstance from the string.
JsonNode bpmnData = new ObjectMapper().readTree(response.body().byteStream());
String bpmn20XmlString = bpmnData.get("bpmn20Xml").asText();
InputStream bpmn20XMLStream = new ByteArrayInputStream(bpmn20XmlString.getBytes(StandardCharsets.UTF_8));
BpmnModelInstance bpmnModelInstance = Bpmn.readModelFromStream(bpmn20XMLStream);
For more details on reading bpmn model:
https://docs.camunda.org/manual/7.12/user-guide/model-api/bpmn-model-api/read-a-model/
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.bpm.example.modelapi;
import static org.assertj.core.api.Assertions.assertThat;
This file has been truncated. show original