Hello,
I have a request in JSON form, I would like to post that json in gzip compressed format to the endpoint that I have on UI,
Is it possible to do that ?
Hey @jaybhanushali !
While Postman does not support external Node.js libraries like zlib
directly in its scripting environment, you can try importing it a different way.
If that doesn’t work, you might consider turning to Newman or the Postman CLI. With Newman, you can integrate Postman collections into scripts and automation pipelines, allowing you to use Node.js and its libraries, including zlib
, more flexibly. You could:
- Create a Node.js script that uses
zlib
to compress your JSON payload. - Use this script to store the compressed payload in an environment variable or a temporary file.
- Trigger your Postman collection using Newman, referencing the stored compressed payload.
- Ensure you set the
Content-Encoding: gzip
header in your request.
This way, you can automate the compression and request sending processes, taking advantage of the rich Node.js ecosystem alongside Newman.
I hope that helps! Let us know if you have any further questions.
it says that " The data in the request body - . This object is immutable and can’t be modified from scripts:" source
I would like to change the body before sending from UI, is this not possible ?
You are correct; Postman doesn’t allow you to modify the request body through pre-request scripts. However, here’s a potential workaround:
- Compress your JSON payload externally, converting the compressed content to a format like Base64.
- Use this Base64 string as your request body in Postman.
- On the server-side, decode the Base64 and decompress it to get your original payload.
If you need to integrate this process into an automated workflow, consider using Newman with Node.js, where you have more flexibility with libraries like zlib.
I hope this provides clarity!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.