'XML Document is not valid - post request

I have API that requires whitelisted IPs. I am trying to send a post request to it, which is in XML format.

The xsd is:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="VW_WCF_SF_VAL_QRY">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="GAS_DAY" type="xs:date"/>
    <xs:element minOccurs="0" name="LDZ">
     <xs:simpleType>
      <xs:restriction base="xs:string">
       <xs:length value="2"/>
      </xs:restriction>
     </xs:simpleType>
    </xs:element>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:schema>

from which, I generated an XML document as so (using an XSD -> XML converter)

data = """<?xml version="1.0" encoding="utf-8"?>
<VW_WCF_SF_VAL_QRY>
<GAS_DAY>2018-02-01</GAS_DAY>
</VW_WCF_SF_VAL_QRY>"""

I have tried passing the following post request

# header = {'Cookie': authentication_cookie}
r = requests.post(url, data=data, headers=header)

But get the following error response:

<?xml version="1.0" encoding="utf-8"?>
<errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://prod-ix.geminints.com:4445/gemini/api/schema/geminiapierror.xsd">
 <errInfo ID="1">
  <errCode>
   GEM_API_ERROR_0001
  </errCode>
  <errDesc>
   XML Document is not valid
  </errDesc>
 </errInfo>
</errors>

I am unsure as to what is causing this.



Solution 1:[1]

Remove this \ character:

</VW_WCF_SF_VAL_QRY\>"""
                   ^

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kjhughes