Byte Array in REST Service response - GET method
I have a REST service which return a byte Array in the response payload. Just the byte Array , nothing else. This byte array is the file sent by the service provider.
How do I map that byte array and get the content and show it on the Pega side ?
1. Mapping the byte array to a temp property, gives me the byte array as a raw string, how do I use that string as a byte array as it is ?
Any other way of mapping the response in the REST response which could help ?
Yes .. we were able to get that working some how with the below code snippet:
java.net.HttpURLConnection httpUrlConn = (java.net.HttpURLConnection)ssURL.openConnection();
//Set the REST request headers and body on httpURLConn using httpUrlConn.setRequestProperty(<HeaderName>, <VALUE>);
java.io.InputStream iStream = httpUrlConn.getInputStream();
java.io.ByteArrayOutputStream buffer = new java.io.ByteArrayOutputStream();
byte bArray=new byte;
bArray = buffer.toByteArray();
HashStringMap aMap = new HashStringMap();
aMap.put( "ContentDisposition", "inline;filename="+FileName);
Response = tools.sendFile(bArray, FileName , false, aMap, true );
Keep up to date on this post and subscribe to comments
- How to handle byte array response coming into Pega?
- How to automate conversion from PNG to PDF, and transition from PDF to byte array, and to store the byte array in Pega
- Sending File as byte content in JSON Request for REST Service
- Setting Response Code in response from authentication activity for a rest service package.
- Getting "com.pega.pegarules.pub.PRException: Exception occurred while mapping incoming response to.response_POST.parts " while calling REST service