Use REST or JSON
REST
CURL
curl get
curl --user demo:demo123 10.40.1.225:80/Elvaco-Rest/rest/system/time
curl post
curl --user demo:demo123 -H 'Content-Type: application/json' http://10.40.1.225:80/Elvaco-Rest/rest/console/command --data '{"command":"status","params":["ver"]}'
python 3
import requests
headers = {
'Content-Type': 'application/json',
}
data = '{"command":"status","params":["ver"]}'
username = 'demo'
passwd = 'demo123'
command = '/Elvaco-Rest/rest/console/command'
url = 'http://10.40.1.225:80'
response = requests.post(url + command, headers=headers, data=data, auth=(username, passwd))
print(response.text)
command = '/Elvaco-Rest/rest/system/time'
response = requests.get(url + command, auth=(username, passwd))
print(response.text)
JSON
CURL
curl --user demo:demo123 -H "Content-Type: application/json" http://10.40.1.225/Elvaco-JSON-RPC/PDB --data '{"jsonrpc": "2.0","method": "pdb.browse", "id": 3}'
python 3
import requests
headers = {
'Content-Type': 'application/json',
}
data = '{"jsonrpc": "2.0","method": "pdb.browse", "id": 3}'
username = 'demo'
passwd = 'demo123'
command = '/Elvaco-JSON-RPC/PDB'
url = 'http://10.40.1.225:80'
#JSON#
data = '{"jsonrpc": "2.0","method": "pdb.browse", "id": 3}'
response = requests.post(url + command, headers=headers, data=data, auth=(username, passwd))
print("POST JSON")
print(response.text)
For JSON there is a help section. With much more examples with curl
Was this article helpful?
Have more questions? Submit a request
Comments (0 comments)