- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
10-25-2022 08:54 AM
Hello,
I'm downloading a zip file via API with this request:
it's supposed that my "response" variable now it's the zip file, however when I try to open, I can't, it's like it doesn't exist. How can be unzipped and extract the .txt file inside?
10-25-2022 05:49 PM
Hi @Josep, I dont know if that is correct. The API response might be a data stream, you will need convert it into a file first, then attempt de-compress.
import requests
r = requests.get("<URL>", stream=True)
with open("<filepath>", 'wb') as f:
for chunk in r.iter_content(128):
f.write(chunk)
10-26-2022 07:21 PM
Hi @Josep, That was shown as an example. Try making the script work outside XSOAR with local Python installation. When you move the script to XSOAR, you will need to replace the file part with fileResult
command.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!