Zipping JSON in servicenow

SwastikC
Tera Contributor

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.

2 REPLIES 2

VIJAY YACHAM1
Tera Contributor

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:

  1. ServiceNow generates the JSON payload.

  2. Sends it to the MID Server via Orchestration Activity or REST.

  3. MID Server compresses (ZIP) it.

  4. 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:

  1. 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.

  2. 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:

  1. ServiceNow sends plain JSON to the middleware.

  2. Middleware compresses it (ZIP).

  3. Sends ZIP to the target API.

Please mark solution as helpful if you found it is useful for you.

 

Thanks,

Vijay

Ankur Bawiskar
Tera Patron
Tera Patron

@SwastikC 

zip file can be created within ServiceNow using flow designer and you can include files into that zip file

did you check the docs?

Zip operation 

also check this link for custom script

Create Zip File From Script 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader