# How to handle binary responses in Postman which when saving, save it as docx file

**URL:** <https://community.postman.com/t/how-to-handle-binary-responses-in-postman-which-when-saving-save-it-as-docx-file/50735>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [August 18, 2023, 4:36pm UTC](https://community.postman.com/t/how-to-handle-binary-responses-in-postman-which-when-saving-save-it-as-docx-file/50735 "2023-08-18T16:36:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunar-module-cosmo10](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@lunar-module-cosmo10](https://community.postman.com/u/lunar-module-cosmo10)\
**Post date:** [August 18, 2023, 4:36pm UTC](https://community.postman.com/t/how-to-handle-binary-responses-in-postman-which-when-saving-save-it-as-docx-file/50735/1 "2023-08-18T16:36:55Z")

</div>

I am trying to process a API response, which is of type binary (please see screen shot of API response about how it looks). I want to perform validation of file contents post downloading/saving it to .docx file. Can any one point me in right direction on how we can achieve the same.  
 ![APIBinaryResponse](https://us1.discourse-cdn.com/getpostman/original/3X/6/8/68b94615d2c632fee0e328a339af936b4d6c98b3.png)

---

<div class="post-metadata">

**Author:** ![kevinc-postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevinc-postman/32/12774_2.png) [@kevinc-postman](https://community.postman.com/u/kevinc-postman)\
**Post date:** [August 21, 2023, 9:29pm UTC](https://community.postman.com/t/how-to-handle-binary-responses-in-postman-which-when-saving-save-it-as-docx-file/50735/2 "2023-08-21T21:29:49Z")

</div>

Hi @lunar-module-cosmo10 !

Great question. Handling binary responses in Postman, especially for files like .docx, should be straightforward once you get the hang of it 🙂

Here’s a step-by-step guide to help you:

1. **Receiving Binary Responses** :

- Ensure your request headers are set up to accept binary data (e.g., `Accept: application/octet-stream`).
- Send the request and wait for the response. The response will look garbled or show up as unreadable text in Postman’s response viewer because it’s a binary representation of the `.docx` file.

1. **Saving the Binary Response** :

- Once you’ve received the binary response, click on the **“Save Response”** button (or right-click in the response section).
- Choose **“Save to a file”**.
- Save the file with a `.docx` extension to your desired location.

1. **Validating File Contents** :

- Since `.docx` files are essentially zipped XML files, you’ll need specialized libraries or tools to read and validate their contents programmatically.
- If you just want to manually verify the contents, you can open the saved `.docx` file using Microsoft Word or a similar word processing software.
- For automated validations, consider using libraries like [mammoth.js](https://github.com/mwilliamson/mammoth.js) (for JavaScript) or [python-docx](https://python-docx.readthedocs.io/en/latest/) (for Python) in your test scripts outside of Postman.

Unfortunately, directly validating the contents of a `.docx` file within Postman’s scripting environment might be a challenge due to the complex nature of Word files. Most users validate such files outside Postman in a more robust development environment tailored to their needs.

Hope that helps! Let us know if you have any other questions.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [November 19, 2023, 9:30pm UTC](https://community.postman.com/t/how-to-handle-binary-responses-in-postman-which-when-saving-save-it-as-docx-file/50735/3 "2023-11-19T21:30:42Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
