Support Article
Connect-REST fails to map response binary stream
SA-22559
Summary
User is on Pega 7.1.7 and is using the Connect-REST to get a binary stream as response. The response body is having a file binary data, which can be pdf, xlsx etc. While mapping the response body which is a binary stream to a Java object on clipboard they are getting the below exception:
com.pega.pegarules.pub.services.InboundMappingException: Could not write response entitiy to output stream
Error Messages
Caused by: java.io.IOException: Attempted read from closed stream.
at com.pega.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:166)
at com.pega.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:197)
at com.pega.apache.http.entity.BasicHttpEntity.writeTo(BasicHttpEntity.java:113)
at com.pega.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:96)
at com.pega.apache.http.conn.BasicManagedEntity.writeTo(BasicManagedEntity.java:114)
at com.pega.pegarules.integration.engine.internal.connect.http.HTTPClient.getReponseData(HTTPClient.java:581)
... 69 more
Steps to Reproduce
- Create a REST service to return a binary file.
- Create a REST Connector in a Pega application to consume the binary response and map it to a Java object on clipboard.
- Create a Data Page or Activity to run the connector.
- The mapping error occurs while running the connector.
Root Cause
A defect in Pegasystems’ code or rules is identified as the root cause of this issue.
Resolution
Apply HFix-27327.
Published April 29, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.