Home > Net >  VAPIX event list through HTTP SOAP request in Python
VAPIX event list through HTTP SOAP request in Python

Time:10-13

I am currently trying to obtain an event list for an AXIS camera through the VAPIX API, and am sending an HTTP SOAP request using the following code. However, I am getting a Response 400. Does anyone know what I'm doing wrong here? The only things I replaced here were the IP, username and password.

A little info on getting the event list through VAPIX: https://www.axis.com/vapix-library/subjects/t10175981/section/t10008227/display

from requests.auth import HTTPDigestAuth
import requests
url = "http://IP/vapix/services"

headers = {"Content-Type" : "application/soap xml; action=//www.axis.com/vapix/ws/event1/GetEventInstances; Charset=UTF-8"}

body = """<SOAP-ENV:Envelope xmlns:SOAP-ENV="//www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="//www.w3.org/2003/05/soap-encoding" xmlns:xsi="//www.w3.org/2001/XMLSchema-instance" xmlns:xsd="//www.w3.org/2001/XMLSchema"><SOAP-ENV:Body><m:GetEventInstances xmlns:m="//www.axis.com/vapix/ws/event1"/></SOAP-ENV:Body></SOAP-ENV:Envelope>"""

response = requests.post(url, auth=HTTPDigestAuth('username', 'password'), data = body, headers = headers)

print(response)

CodePudding user response:

If anyone has the same issue, after contacting AXIS support, I found out my SOAP body content was incorrect, and should be the following:

body = """
  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
    <SOAP-ENV:Body>
      <m:GetEventInstances xmlns:m="http://www.axis.com/vapix/ws/event1"/>
    </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>"""

This worked.

  • Related