XML Parsing via Endpoint

djoguns
Level 2
XML Parsing via Endpoint

Hi,

Hope someone can help out with this as soon as possible.

This approach has been done many times outside of DSS but we want to take advantage of the API endpoint by ensuring we have a data sent via the API Point, for example:

results = request(url, param)

url: endpoint, param: data or dictionary access of our data.

I understand there is the webapp route which does not serve the purpose needed. Using Flask API, this has been implemented simply as follows in the library editor and called via the endpoint but it failed considerably during the API call.

# Library Editor
app = Flask(__name__)
@app.route("/", methods=['POST'])
def get_xml():
    args = parser.parse_args()
    user_data = args['xml_text']
    xml_data = request.form['xml']
    content_dict = xmltodict.parse(xml_data)
    return content_dict

# Endpoint Call
from librarymodule.filename import get_xml
def api_py_function(data):    
    xml_raw = get_xml(data)
    return xml_raw

Thanks.

djoguns

0 Kudos
1 Reply
SarinaS
Dataiker

Hi @djoguns ,

Can you post the error message you are seeing when the failure you reference occurs?  If possible, can you provide some more detail about when the failure is occurring, and how you are triggering this failure?  

It sounds like you provided the Flask code here as an example of the type of XML parsing you want to do, but your goal is not to create a Flask app. If that is the case, can you also provide the code that is not working as expected? 

Thanks,

Sarina

0 Kudos