Set HttpHeader on Published Rest to Get FileDocument

3
A published REST-service contains a GET operations. This operation returns one (.pdf) document. Calling the service returns the (.pdf) FileDocument.   However, when opening the .pdf a error appears, the file is corrupt, damaged or not correctly decoded.  In the GET operation, an HTTP Header is created with Key 'Content-Type' and Value 'application/octet-stream' but this doesn't solve the problem, also application/x-binary and application/pdf dont solve it. My best guess is that other HTTP Header values.  Question: Which http header are needed and in the request MF or response MF? Image 1: Request MF   Image 2: Response MF   Update 1: Problem solved. Modelling mistake 1:  In the response handling of the Call REST action, store in file document was selected. This saves the complete response in a filedocument in its contents, but I had to MAP te response to the domain model. Hence, Apply import mapping had to be selected.   Modelling mistake 2:  After selecting Apply import mapping, the boolean A List was choosen for The response contains. The response contains only one object, and therefore the response does not contain the [ & ] around it. The import mapping did not work because in this case it expects one object. Hence. An object was selected for The response contains boolean.   Model bug? Confident this was the right setup, it still did not work. Therefore, I have deleted the request microflow and import mapping, and recreated both After this, I worked.   Note: Adding the HTTP Headers did not have any influence. Without it, I can still map any filetype.   Thanks for helping me out anyway!    
asked
5 answers
1

You need at least the content type header:

Content-Type: application/pdf

 

answered
1

In the Response MF, you should add a 'Create Object' activity.

Type: System.HttpHeader

Key: 'Content-Type'

Value: 'application/pdf'

HttpHeaders: $HttpResponse

answered
0

Try to add Accept headers: 

Accept: application/pdf
answered
0

Thijs, Does the pdf become corrupt upon creation in your service or during transport?

answered
0

Have you tried consuming the service using for example Postman? This is generally a quicker and easier way to test what headers to send and it will even give you some proper error messages.

answered