尝试将GET请求发送到systeminfo.xml

时间:2018-09-06 17:10:14

标签: python rest iis request

我想在XProtect Corporate帐户上获取设备的配置,我正在关注这篇文章

http://doc.developer.milestonesys.com/html/reference/protocols/imageserver_getdevices.html

但是我每次都收到401,未经授权。

直到现在,我已经设法对自己进行身份验证并获得了令牌,因为我拥有公司帐户,所以我需要发送令牌进行授权,我正在python中使用request lib发送这样的GET请求< / p>

head = {'Authorization': 'Token {}'.format(myToken)}

response = requests.get('http://server-ip/rcserver/sysmteminfo.xml', headers=head)

print response

我不确定如何在此get请求中发送令牌

任何帮助将受到高度赞赏

1 个答案:

答案 0 :(得分:0)

所以我终于能够获得服务器上所有设备的配置。问题是,上述方法仅适用于XProtect Enterprise和XProtect Professional,如果您具有XProtect Corporate,则需要NTLM身份验证,并且必须在服务器SOAP协议上调用GetConfiguration函数。

r2= '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetConfiguration xmlns="http://videoos.net/2/XProtectCSServerCommand"><token>' + str(myToken) + '</token></GetConfiguration></soap:Body></soap:Envelope>'
data_len = str(len(r2))
s.sendall("POST /ManagementServer/ServerCommandService.svc HTTP/1.1\r\nHost: server-ip\r\nContent-Type: text/xml; charset=utf-8\r\nAuthorization: Basic (base64 encoded '*[BASIC]\username:password*')\r\nContent-Length: "+data_len+"\r\nSOAPAction: http://videoos.net/2/XProtectCSServerCommand/IServerCommandService/GetConfiguration\r\n\r\n"+ r2)