I am trying to consume a REST service which returns an image, but this results in an error. I have configured the Call REST Service action to store the response in a string: since I don't get a JSON object, I don't see how I can use an import mapping.
In this blog post, it is mentioned that the representation of a resource can vary: "Several common representations are XML, JSON, HTML, or binary data such as an image or PDF file." Can I consume such a service through the native Call REST Service action?
The error that I get:
com.mendix.modules.microflowengine.MicroflowException: Error calling REST service
at CustomerApi.GetThumbnail (CallRest : 'Call REST (GET)')
at Tests.TEST_IVK_GetThumbnail (SubMicroflow : 'GetThumbnail')
Advanced stacktrace:
at com.mendix.integration.actions.microflow.RestCallAction.handleResponse(RestCallAction.scala:70)
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.read1(BufferedReader.java:210)
at java.io.BufferedReader.read(BufferedReader.java:286)
at java.io.Reader.read(Reader.java:140)
at scala.io.BufferedSource.mkString(BufferedSource.scala:96)
at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$com$mendix$integration$actions$microflow$RestCallAction$$extractString$1.apply(RestCallAction.scala:90)
at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$com$mendix$integration$actions$microflow$RestCallAction$$extractString$1.apply(RestCallAction.scala:90)
at scala.Option.map(Option.scala:146)
at com.mendix.integration.actions.microflow.RestCallAction.com$mendix$integration$actions$microflow$RestCallAction$$extractString(RestCallAction.scala:90)
at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$handleResponse$1.apply(RestCallAction.scala:67)
at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$handleResponse$1.apply(RestCallAction.scala:67)
at com.mendix.integration.actions.ServiceCallResult.parseResponse(ServiceCallResult.scala:39)
at com.mendix.integration.actions.ServiceCallResult.toMendixResult(ServiceCallResult.scala:33)
at com.mendix.integration.actions.microflow.RestCallAction.handleResponse(RestCallAction.scala:67)
at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:42)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260)
at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248)
at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168)
at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)
at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:174)
at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:459)
at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:43)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260)
at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248)
at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168)
at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)
at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:174)
at com.mendix.core.component.InternalCore.execute(InternalCore.java:377)
at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:135)
at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:282)
at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:277)
at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:277)
at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:144)
at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)
at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:146)
at scala.util.Try$.apply(Try.scala:192)
at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:140)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:136)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)