I'm trying to use camunda's REST API method, /process-definition/key/{key}/diagram, to return the image of the process definition.
When I run the following, the status is 200 and the data comes back as binary but not base64 encoded and the image doesn't render (note: when I have 'dataType' in, I get status=200 but err=No conversion from text to img/png).
Note: I ran it in google chrome Advanced Rest Client and same results; response header says content type is img/png
Does anyone know how to get this to render as an image? Thanks - Roger.
<html>
<head>
<title>Test</title>
</head>
<body>
<div id="getimage">Get image</div>
<div id="img123"></div>
<script src="http://ift.tt/13qgtmt"></script>
<script>
$(document).ready(function(){
$('#getimage').click(function(){
getImage();
});
});
function setImage(data){
$("#img123").append('<img src="data:image/png;base64,' + data + '"/>');
}
function getImage() {
console.log('Entered getImage!');
$.ajax({
url:'http://ift.tt/1akKvfK',
type: 'GET',
crossDomain: true,
headers: { "user":"demo","pwd":"demo","Access-Control-Allow-Origin":"http://127.0.0.1:8080/"},
//dataType: 'img/png',
success: setImage,
error: function (xhr, ajaxOptions, err) {
alert('ERROR: status=' + xhr.status + ' error=' + err);
}
});
}
</script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire