Using ISAPI to search and download from SD card

Nov 20, 2016
18
1
This link has a how to guide for using the storage management aspects of the http api:

http://www.hikvisioneurope.com/port...function of Hikvision IP Camera(External).pdf


Much of it works as described. However, some essential parts of it seem not to work. Or at least, I can't figure out how to make them work. My goal is to download videos from the SD card programmatically. The guide explains that this can be done by doing a search query, and some returned information to download specified files.

Except that I can't get the search query to work, I always get:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<requestURL>/ISAPI/ContentMgmt/search</requestURL>
<statusCode>4</statusCode>
<statusString>Invalid Operation</statusString>
<subStatusCode>methodNotAllowed</subStatusCode>
</ResponseStatus>

methodNotAllowed? Is this more intentionally crippled functionality that used to work?

Has anyone been able to make this work? It appears I'm in mostly uncharted waters here, based on some google searching.
 
I was actually able to make this work after inspecting traffic generated by the web interface using wireshark.

An example of a valid request looks like:
Code:
<?xml version="1.0" encoding="utf-8"?>
<CMSearchDescription>
<searchID>anythinghere</searchID>
<trackList>
  <trackID>101</trackID>
</trackList>
<timeSpanList>
  <timeSpan>
    <startTime>2016-11-20T00:00:00Z</startTime>
    <endTime>2016-11-20T23:59:59Z</endTime>
  </timeSpan>
</timeSpanList>
<maxResults>40</maxResults>
<searchResultPostion>40</searchResultPostion>
<metadataList>
  <metadataDescriptor>//metadata.psia.org/VideoMotion</metadataDescriptor>
</metadataList>
</CMSearchDescription>

which can be sent to the server from a file with:

Code:
curl -X POST -d @file http://<user>:<pass>@<camera-ip>/ISAPI/ContentMgmt/search

and you should get back a response containing a list of videos. The howto shows how to use the response to generate download commands.
 
Has anyone been able to make this work? It appears I'm in mostly uncharted waters here, based on some google searching.
I think you are, not something I have done.
I have found though, when exploring the published APIs, that not everything works, it's presumably model and firmware dependent.
 
I am using a Hitosino, AKA knock-off version, but I think it should be the same.

@anderson110, did you ever get past the search API to the download? I was able to successfully search using code similar to what you laid out, above.

At the download portal, I see the same files that were reported through the /ContentMgmt/search API, but if I try to download one of the files and watch the packets, I see a 400 error when I watch the network traffic.

I then submitted the same request through curl, with no luck. I got:

1. An authentication error. So I added -n, to provide my credentials through netrc.
2. A status of "Invalid Content." So I removed the long URL with the ampersands, improperly rendered in the GET request that I copied from the browser. I placed that information into an xml file, loaded through -d.
3. statusString of "Invalid Content" and "subStatusCode" of "badXmlContent", because I did not convert & to &amp; so I did that. That gave me a playbackURI identical to the one reported through the (functioning) search API.
4. statusString of Invalid Operation and subStatusCode>methodNotAllowed for
curl -n -d @[download xml file] '[http to my camera ip]/ISAPI/ContentMgmt/download'

5. I also tried with a token and -n, and got the same error. With just the token, literally nothing happened.

So the search API is working for me, but I cannot download files.

Using ffplay, I can play the files fine over rtsp, but this is at "1x speed," which is really not what I'm looking for.

Ultimately I then tried simply removing the micro SD card from the device to copy the data, but the formatting was not readable on a Mac... and I was not able to get a driver to read it.

Thanks for any advice.
 
I download via the NVR using playbackURI from json XML response like this..

My playbackURI
Code:
rtsp:/192.168.1.200/Streaming/tracks/101/?starttime=20200826T232510Z&endtime=20200826T235959Z&name=00000000808000000&size=1064978720

My curl request
Code:
curl -d "<downloadRequest><playbackURI>rtsp:/192.168.1.200/Streaming/tracks/101/?starttime=20200826T232510Z&amp;endtime=20200826T235959Z&amp;name=00000000808000000&amp;size=1064978720</playbackURI><userName>admin</userName><password>password</password></downloadRequest>" http://admin:password@192.168.1.200/ISAPI/ContentMgmt/download -o W:\temp\test.mp4
 
Last edited:
Thanks, but that is basically the same as #4 above, except that I had the xml in a file instead of inline. And it gives me the same result:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.std-cgi.com/ver20/XMLSchema">
<requestURL>/ISAPI/ContentMgmt/download</requestURL>
<statusCode>4</statusCode>
<statusString>Invalid Operation</statusString>
<subStatusCode>methodNotAllowed</subStatusCode>
</ResponseStatus>

I am coming to suspect that it is simply not supported with this camera / firmware.