Bigfix create custom site rest api xml error

Hi,
I am making post api to create custom site in bigfix and getting xml pasring error.

Error:XML parsing error: invalid document structure Line 1, Character 1

PFB:
with open(‘site.xml’, ‘rb’) as xml:
xmldata = ‘’.join(xml.readlines())
r = requests.post(‘https://{server}:{port}/api/sites’, auth=(’{username}’, ‘{password}’), data=xmldata)
print(r.text)

site.xml:

<?xml version="1.0" encoding="utf-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
        <CustomSite>
                <Name>TestSite</Name>
                <GatherURL>http://bigfix.test:52311/cgi-bin/bfgather.exe/CustomSite_TestSite</GatherURL>
                <Description></Description>
                <Domain>BESC</Domain>
                <GlobalReadPermission>true</GlobalReadPermission>
                <Subscription>
                        <Mode>None</Mode>
                </Subscription>
        </CustomSite>
</BES>

I edited your post to put the xml in code tags (the </> symbol in the formatting bar. Hopefully that helps with responses.

Hi,
I tried with the edited XML its giving me same error.

Hello you xml file works to me. I have used the “iem” CLI to import it quickly:

./iem post /TEM/test_site.xml sites

<?xml version="1.0" encoding="UTF-8"?> TestSite

The site “TestSite” is successfully created. I suspect it is a problem with the the REST client.