0

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.

Gregory Sky
  • 140
  • 9

2 Answers2

0

Your payload does not seem to be correct. Please change it from CA32CBsadasdasda1A83 to any type of string but formatted in this manner: C92DC285-8F30-0001-40C6-F0EFA8FB18B5. As shown here https://stackoverflow.com/a/62505522

R_V
  • 41
  • 8
0

Actually, I didnt realise, but this needs to be a POST request, while I was utilising GET request. Not deleting the question, as perhaps someone else is doing the same and might find this answer helpful.

Gregory Sky
  • 140
  • 9