Need Help with Decompressing GZIP Input in Scripted REST API (Yokohama)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 03:15 AM
Hi all,
I'm working on a Scripted REST API in a scoped application , and I need to accept gzip-compressed data with Content-Type: text/plain; charset=ISO-8859-1. I'm sending raw GZIP binary via Postman, and I’m handling the request in a custom Scripted REST resource.
Here’s what I’ve done so far:
Request Setup:
Content-Type: text/plain; charset=ISO-8859-1
Content-Encoding: gzip
Body: GZIP-compressed .txt file uploaded as binary
Resource Config:
Enforce strict content negotiation: Unchecked (to allow text/plain)
Reading the raw input stream from request.body.dataStream
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
try {
var contentType = request.getHeader('Content-Type');
var contentEncoding = request.getHeader('Content-Encoding');
if (contentType !== 'text/plain; charset=ISO-8859-1' || contentEncoding !== 'gzip') {
response.setStatus(400);
return { error: 'Invalid headers' };
}
var inputStream = request.body.dataStream;
gs.info("INPUT:---" + inputStream); // shows: com.glide.communications.GlideScriptableInputStream@xxxx
// Trying to decompress GZIP from inputStream here
response.setStatus(200);
return { status: 'success' };
} catch (e) {
gs.error('Error: ' + e);
response.setStatus(500);
return { error: e.toString() };
}
})(request, response);
Questions :
1) Is this the correct way to do this? If so how can i decompress and decode it to original format?
2) as I'm sending file as binary from postman is this the correct way of testing this particular endpoint?
Any leads will be appreciated Thank you.