Skip to main content

json result from an HTTP GET to base64

  • August 11, 2022
  • 4 replies
  • 20 views

Forum|alt.badge.img+2

is there a way to take a json result from an HTTP GET and convert to base64 within siemplify? I'm overlooking if such an action exists. Thanks

4 replies

Forum|alt.badge.img+2
  • Author
  • New Member
  • August 14, 2022

or really any form of Encode Base64 function. I might be overlooking it or don't have the right integration/powerup installed. :)


Forum|alt.badge.img+2
  • Author
  • New Member
  • August 14, 2022

well there didn't seem to be one available, so i wrote one based on the Decode Base64 action. here it is if you ever want it for yourself.


Forum|alt.badge.img+2
  • Author
  • New Member
  • August 14, 2022

# desc: encode b64 action, written by Jim T
# ver : v1.0
# date: 7/27/2022

from SiemplifyAction import SiemplifyAction
from SiemplifyUtils import output_handler

import json
import base64

def main():
siemplify = SiemplifyAction()
text_input = siemplify.parameters.get("Text Input")
encoding = siemplify.parameters.get("Encoding")

text_bytes = text_input.encode(encoding)
encoded_content = str(base64.b64encode(text_bytes), 'UTF-8')
result = {'encoded_content': (encoded_content)}

siemplify.result.add_result_json(json.dumps(result))
siemplify.end('Content was succesfully encoded to base 64.', True)

if __name__ == "__main__":
main()


Forum|alt.badge.img+13

This comment was originally sent by Tom Fridman
Wonderful @James_Tippen