Zipping JSON in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2025 06:50 AM
I'm trying to develop a use case where my app needs to form JSON on the servicenow and zip that JSON and send it to an external API. Despite multiple attempts I'm unable to find a workaround.
I would love to know if there is something we can do to zip JSON contents on servicenow side. This is a major blocker as of now and would love hear any workaround. Looking forward to further guidance.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2025 10:59 PM
Hello @SwastikC,
ServiceNow doesn't natively support zipping (compressing) files or content like JSON directly in the platform using standard Glide APIs. However, there are some workarounds depending on your flexibility and integration constraints. Below are practical options you can consider:
Option 1: Use a MID Server (Recommended if available
You can offload the compression logic to a MID Server (ServiceNow's agent installed on your infrastructure).
Write a script in PowerShell or Python on the MID Server that:
Retrieves the JSON (sent by the instance via REST or orchestration)
Zips it
Sends it to the external API
Use Case Flow:
ServiceNow generates the JSON payload.
Sends it to the MID Server via Orchestration Activity or REST.
MID Server compresses (ZIP) it.
MID Server sends it to the external API.
Option 2: Use a Scripted REST API with Base64-encoded ZIP
If you must stay within ServiceNow and the receiving system accepts Base64 or can unzip encoded content:
Use a JavaScript compression library (like pako or zip.js) inside a Scripted REST API or UI Script, though this is mostly browser-side — not reliable server-side.
Alternatively, you can:
Generate JSON string.
Base64 encode it (not compress, but somewhat similar effect).
Send it with a Content-Encoding: base64 header.
Let the external API decode it.
Option 3: External Middleware (Node.js, Azure, AWS Lambda)
If MID Server is not feasible, use a small middleware layer (e.g., AWS Lambda, Azure Function, Node.js microservice).
Flow:
ServiceNow sends plain JSON to the middleware.
Middleware compresses it (ZIP).
Sends ZIP to the target API.
Please mark solution as helpful if you found it is useful for you.
Thanks,
Vijay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2025 11:19 PM
zip file can be created within ServiceNow using flow designer and you can include files into that zip file
did you check the docs?
also check this link for custom script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader