0
votes

Let's say, below is the multipart/form-data I want to create:

POST /ISAPI/Intelligent/FDLib/FaceDataRecord?format=json 
Accept: text/html, application/xhtml+xml,
Accept-Language: us-EN
Content-Disposition: form-data; name="FaceDataRecord";
Content-Type: application/json
Content-Length: 9907

{
"name": "Eric",
"gender": "male",
"bornTime": "2004-05-03",
"city": “130100”
}
-----------------------------7e13971310878
Content-Disposition: form-data; name="FaceImage";
Content-Type: image/jpeg
Content-Length: 9907
    
......JFIF.....`.`.....C...........     .
..
................. $.' ",#..(7),01444.'9=82<.342...C.            ....
-----------------------------7e13971310878--

How can I create this form-data and then Serialize it before I pass/copy it to IntPtr?

Any help would be massively appreciated.

1
Where do you pass the data? Because you only give the format data and the http header, they are different in various frameworks.Karney.
@Karney. to the device(hikvision face terminal module to be exact) through ISAPI request.Standley Peter

1 Answers

0
votes

2 API for add images and register for HIK camera Admin page:

  1. Add user curl 'http://%20:%[email protected]/ISAPI/AccessControl/UserInfo/Record?format=json'
    -H 'Connection: keep-alive'
    -H 'Cache-Control: max-age=0'
    -H 'Accept: /'
    -H 'X-Requested-With: XMLHttpRequest'
    -H 'If-Modified-Since: 0'
    -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36'
    -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
    -H 'Origin: http://192.168.0.10'
    -H 'Referer: http://192.168.0.10/'
    -H 'Accept-Language: en-US,en;q=0.9,vi;q=0.8,en-GB;q=0.7'
    -H 'Cookie: language=en; WebSession_83FEDD998A=fd7b6bdef0cfb3fea119cef828eb3b585bf740ac6022d6fd90c1afe57f45f6fb'
    --data-raw '{"UserInfo":{"employeeNo":"u01","name":"user name","userType":"normal","gender":"male","doorRight":"1","maxOpenDoorTime":0,"RightPlan":[{"doorNo":1,"planTemplateNo":"1"}],"Valid":{"enable":true,"beginTime":"1970-01-01T00:00:00","endTime":"2037-12-31T23:59:59","timeType":"local"}}}'
    --compressed
    --insecure

  2. Upload image form data api: curl 'http://192.168.0.10/ISAPI/Intelligent/FDLib/FaceDataRecord?format=json'
    -H 'Connection: keep-alive'
    -H 'Accept: /'
    -H 'X-Requested-With: XMLHttpRequest'
    -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36'
    -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundarybhUby8nZAMaD5fRS'
    -H 'Origin: http://192.168.0.10'
    -H 'Referer: http://192.168.0.10/'
    -H 'Accept-Language: en-US,en;q=0.9,vi;q=0.8,en-GB;q=0.7'
    -H 'Cookie: language=en; WebSession_83FEDD998A=fd7b6bdef0cfb3fea119cef828eb3b585bf740ac6022d6fd90c1afe57f45f6fb'
    --data-raw $'------WebKitFormBoundarybhUby8nZAMaD5fRS\r\nContent-Disposition: form-data; name="FaceDataRecord"\r\n\r\n{"faceLibType":"blackFD","FDID":"1","FPID":"u01","name":"user name","gender":"male"}\r\n------WebKitFormBoundarybhUby8nZAMaD5fRS\r\nContent-Disposition: form-data; name="img"; filename="my-image.jpg"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundarybhUby8nZAMaD5fRS--\r\n'
    --compressed
    --insecure