Sending XML Payload and Converting XML Response to JSON with Python
- By : Mydatahack
- Category : Data Engineering, Data Ingestion
- Tags: Python, QAS, XML
If you need to interact with a REST endpoint that takes a XML string as a payload and returns another XML string as a response, this is the quick guide if you want to use Python.
If you want to do it with Node.js, you can check out the post here.
Just like the example with Node.js, we will use QAS endpoint (see more info on this in the intro of the node.js version post).
The idea is very simple. We will pass the XML payload as a string and convert the response XML string to a dictionary by using xmltodict and parse it to JSON. For an API call, we use the requests module.
That’s it. Pretty easy!