I have tried doing the above with the foloowing:
import requests
from requests.auth import HTTPDigestAuth
headers = {'Content-Type': 'application/xml'}
output = requests.post("http://{}/{}".format(targetIP,apiPath),
auth=HTTPDigestAuth(login, password), data=payload, headers=headers, timeout=30)
This code, works for all post requests where payload is not needed. I am getting beautiful xml responses and everything is dandy.
However, as soon as I tried running this api call:
ISAPI/ContentMgmt/logSearch
with this as payload:
"""<?xml version="1.0" encoding="UTF-8"?>
<CMSearchDescription>
<searchID>CA32CBsadasdasda1A83</searchID>
<metaId>log.std-cgi.com/Operation/devicePowerOn</metaId>
<timeSpanList>
<timeSpan>
<startTime>2023-02-09T00:00:00Z</startTime>
<endTime>2023-03-09T23:59:59Z</endTime>
</timeSpan>
</timeSpanList>
<maxResults>100</maxResults>
</CMSearchDescription>"""
I started getting this in response:
<?xml version="1.0" encoding="UTF-8" ?>
<ResponseStatus version="1.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<requestURL>/ISAPI/ContentMgmt/logSearch</requestURL>
<statusCode>5</statusCode>
<statusString>Invalid XML Format</statusString>
<subStatusCode>badXmlFormat</subStatusCode>
</ResponseStatus>
I admit I am a bit stuck on this. I got the XML payload directly from the browser and the xml is exactly as the one used by the Hikvision's NVR homepage that uses ISAPI calls, with changed searchID of course.
I really dont know what is wrong with this and if anyone has any ideas, they will be greatly appreciated.
Just and FYI, I have already tried googling this particular problem of mine and came accross this question: Hikvision log search REST API (POST METHOD) giving Invalid XML Format
Unfortunatelly, this hasnt improved my odds.