http request in Python

Hi,

i want to integrate milestone mobile server protocol in my python application. But when i try to connect to the mobile server i get the following error:

<HTML><BODY><p><b>Mobile Server - Incorrect command format - Check syntax</b></p></BODY></HTML>

This is the source code i use:

import requests
 
# Function definition is here
def generateXmlMessage(options):
    paramsXML = '';
    connectionId = '';
    
    if 'inputParams' in options:
        for key in options['inputParams'].keys():
            paramsXML += '<Param Name="' +key+ '" Value="'+options['inputParams'][key] + '"/>'
        
    if 'connectionId' in options:
        connectionId = '<ConnectionId>'+options['connectionId']+'</ConnectionId>'
        
    s = ('<?xml version="1.0" encoding="UTF-8"?>'
         '<Communication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xlmns:xsd="http://www.w3.org/2001/XMLSchema">'
         ''+connectionId+''
         '<Command SequenceId="'+options['sequenceId']+'">'
         '<Type>Request</Type>'
         '<Name>'+options['command']+'</Name>'
         '<InputParams>'+paramsXML+'</InputParams>'
         '</Command>'
         '</Communication>')
    
    return s
# Principal program
 
options = {'sequenceId':'10','command':'Connect', 'inputParams' : {'ProcessingMessage':'No'}}
xmlResp = generateXmlMessage(options)
 
print(xmlResp)
 
headers = {'Content-Type': 'text/xml'}
 
print(requests.post('http://192.168.1.20:8081/XProtectMobile/Communication', data=xmlResp, headers=headers).text)

Any idea? Any help?

Thanks in advance

Try to compare with the Mobile Server protocol sample. Try to see if your Python application sends the same as the sample does.