How to retrieve a binary file by a rest Call?

1
Hi, I should make a rest call that returns as a binary file. (For example Content-type: application/pdf, but in the end it should recieve all kinds of documents,images). Does someone has an example of this? I don’t seem to find it in the academy/forum. Thanks in advance
asked
2 answers
4

Bregt, 

 

You should be able to map binary to a filedocument, this can be achieved in the import mapping of the REST Call action. The stacktrace points to a security problem.

  • Are you sure you get a response (double check via the console log, increase the log level of the REST consume node).
  • Is authentication required?
  • Are there access rules on the entity you are creating? You could try to first make a call in Postman, if you get a request than make the same call via a mendix microflow. 
answered
0

I tried to put the application/pdf into an empty object with interface system.FileDocument & return it as a filedocument stocked in a variable:
Let me know if you need more screenshots.


I get this error:

com.mendix.modules.microflowengine.MicroflowException: Error calling REST service
    at RESTconsume.Microflow_IRISNext_RetrieveBinary (CallRest : 'Call REST (GET)')

Advanced stacktrace:
    at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:79)

Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: java.security.PrivilegedActionException: org.apache.http.client.ClientProtocolException
    at com.mendix.integration.util.PrivilegedUtil$$anonfun$withPrivileged$2.applyOrElse(PrivilegedUtil.scala:17)

Caused by: java.security.PrivilegedActionException: null


 

answered