I am trying to parameterize my soap request envelope. The envelope is written in xml, but it has embedded json for the query data. ex: parameter1_value = "2025/06/18 00:00:00-2025/06/18 23:59:59" parameter2_value = "World Arena" json_step = { "QueryData_V1":{ "AuthCode":"itsAsecret", "ItemType":"Ticket", "ResultType":"Details", "ResultFormat":"Standard", "Filters":[{ "Field":"CreateDate", "Operation":"TIME_BETWEEN", "Value":{parameter1_value}},{ "Field":"center", "Operation":"EQUALS", "Value":{parameter2_value} }] } } soap_envelope_mask = f"""<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem='http://tempuri.org/"> <soapenv:Header></soapenv:Header> <soap:Body> <tem:QueryData> <!--Optional:--> <tem:jsonRequest> {json_step} </tem:jsonRequest> </tem:QueryData> </soap:Body> </soapenv:Envelope>""" if I try to use soap_envelope_mask.format(**json_step) it gets a KeyError:'"QueryData_V1"' but that is how the envelope is defined. I have also tried many ways to get the json (json.dumps, json.loads, format into the xml, whatever I have try, the json loses it's format or it doesn't indent the JSON portion within the XML and the soap request gets a 500 return. if I create it without the values instead of parameters it works fine. If anyone has come across this issue I would appreciate any suggestions Continue reading...