1

With this code, I was able to get past the Digest Authentication step and get a 200 ok back.

This is my VBscript code:

Option Explicit
Dim restReq, url
Dim jsontext, headerText
Dim fso1 : Set fso1 = CreateObject("Scripting.FileSystemObject")
Dim file1 : Set file1 = fso1.OpenTextFile("\\uspmuusrichm1a\users-h\nguyenhv\2018\PP camera system M.1879\document\Axis decoder\myfile.txt", 2, True)
headerText = "username="&"root"&", "&"realm="&"axis"&", "&"nonce="&"cd0357704fb04263a8203225579087d7"&", "&"uri="&"/axis-cgi/decoder.cgi"&", "&"algorithm="&"MD5"&", "&"response="&"385e2c4ad1be0feb5b8fa453f88e1c1b"&", "&"opaque="&"384b4e29e47341b6a967d94dc6a2c7e2"
Set restReq = CreateObject("MSXML2.serverXMLHTTP")
url = "http://10.67.72.130/axis-cgi/decoder.cgi"
jsontext = "{"&"apiVersion"&": "&"1.0"&" ,"&"context"&": "&"123"&"1.0"&" ,"&"method"&": "&"getCapabilities"&"}"
restReq.open "POST", url, false
restReq.setRequestHeader "Content-Type","application/json"
restReq.setRequestHeader "authorization","Digest " & headerText
restReq.send (jsontext)
file1.WriteLine "Status_Response : " & restReq.Status
file1.WriteLine "HEADER_RESPONSE : " & restReq.getAllResponseHeaders
file1.WriteLine "BODY_RESPONSE : " & restReq.responseText
file1.Close

And this is my decoder response:

Decoder response
Status_Response : 200
HEADER_RESPONSE : Date: Sat, 31 Jan 1970 16:25:20 GMT
Content-Length: 101
Content-Type: text/html; charset=UTF-8
Server: TornadoServer/4.0.2
Vary: Accept-Encoding
BODY_RESPONSE : {"error": {"message": "None", "code": 202}, "context": "None", "apiVersion": "1.0", "method": "None"}

With the error code 202, according to the decoder manual, error code “202” means

invalid JSON.

Which means that my text body on the request is not valid.
My translation from the JSON text string is:

{
  "apiVersion": "1.0",
  "context": "123",
  "method": "getViewConfiguration"
}

But it does not seem to be correct?
Last hurdle, any help is appreciated!

zx485
  • 28,498
  • 28
  • 50
  • 59

1 Answers1

1

Hallelujah !!

Vbscript

Option Explicit
Dim restReq, url
Dim jsontext, headerText
Dim fso1 : Set fso1 = CreateObject("Scripting.FileSystemObject")
Dim file1 : Set file1 = fso1.OpenTextFile("\\uspmuusrichm1a\users-h\nguyenhv\2018\PP camera system M.1879\document\Axis decoder\myfile.txt", 2, True)
headerText = "username="&"root"&", "&"realm="&"axis"&", "&"nonce="&"cd0357704fb04263a8203225579087d7"&", "&"uri="&"/axis-cgi/decoder.cgi"&", "&"algorithm="&"MD5"&", "&"response="&"385e2c4ad1be0feb5b8fa453f88e1c1b"&", "&"opaque="&"384b4e29e47341b6a967d94dc6a2c7e2"
Set restReq = CreateObject("MSXML2.serverXMLHTTP")
url = "http://10.67.72.130/axis-cgi/decoder.cgi"
jsontext = "{""apiVersion"": ""1.0"", ""context"": ""123"", ""method"": ""getCapabilities""}"
restReq.open "POST", url, false
restReq.setRequestHeader "Content-Type","application/json"
restReq.setRequestHeader "authorization","Digest " & headerText
restReq.send (jsontext)
file1.WriteLine "Status_Response : " & restReq.Status
file1.WriteLine "HEADER_RESPONSE : " & restReq.getAllResponseHeaders
file1.WriteLine "BODY_RESPONSE : " & restReq.responseText
file1.Close

Decoder response Status_Response : 200 HEADER_RESPONSE : Date: Sat, 31 Jan 1970 18:49:39 GMT Content-Length: 215 Content-Type: text/html; charset=UTF-8 Server: TornadoServer/4.0.2 Vary: Accept-Encoding

BODY_RESPONSE : {"data": {"audioCodecs": [], "overlappingPanes": "false", "videoCodecs": ["H.264", "MJPEG", "MPEG4"], "resolution": "1920x1080", "maxStreams": 16}, "context": "123", "apiVersion": "1.0", "method": "getCapabilities"}