Api device disable

Albertus7 years ago

Good Day

How can I disable unit via api as admin?

Thank you
Albertus Geyser

Anton Tananaev7 years ago

You can use devices endpoint to disable units. Check official web app for example.

Albertus7 years ago

Thank You Anton

I want to use python external accounting software, will this work?
Will this show an api call to do this?

Anton Tananaev7 years ago

I don't know anything about your system, but it's definitely possible to do an API call with python. I suggest you to look at what official web app sends. I don't understand the second question.

Albertus7 years ago

Good Day

Would api call to disable use this: PUT /devices/{id}?

Or do i miss your explanation?

Thank You

Anton Tananaev7 years ago

Yes, that's the right request.

Albertus7 years ago

PUT /devices/{id}/disabled=true?

Or

PUT /devices/{id}/Disabled=true

??

Anton Tananaev7 years ago

Neither. Check what official web app sends and don't guess.

Albertus7 years ago

Good Day

Please explain how or teach me please not sure how to check.

Thank You

Anton Tananaev7 years ago

Disable or enable device and check network request in the browser developer console.

Albertus7 years ago

Hi Anton

I Get the following:

http://mydomain.co.za:8082/api/devices/5

Params: _dc 1520800779424

Response Headers:

Access-Control-Allow-CredentialstrueAccess-Control-Allow-Headersorigin, content-type, accept, authorizationAccess-Control-Allow-MethodsGET, POST, PUT, DELETE, OPTIONSAccess-Control-Allow-Origin*Content-Length250Content-Typeapplication/jsonDateSun, 11 Mar 2018 20:39:40 GMTServerJetty(9.2.24.v20180105)

Please help . . .

Thank You

Albertus6 years ago

Good Day Anton

Had a look for a while now and find the following:

http://domain.com:8082/api/devices/1?_dc=1527383511088

What does Query string: "?_dc=1527383511088" mean when selecting disabled and save settings?

I get following from params send:

JSON=
attributes	{}
category	default
contact	
disabled	true
geofenceIds	{}
groupId	1
id	1
lastUpdate	2018-05-17T19:48:17+02:00
model	Huawei
name	Huawei
phone	+27877708543
positionId	21926
status	offline
uniqueId	671996

Please help how to disable/enable device with api.

Thank You

Albertus Geyser

Anton Tananaev6 years ago

You don't need _dc query string parameter. It's something that ExtJS library adds automatically to disable cache, but not used anywhere.

Albertus6 years ago

If this my python coding:

import requests
import json

url = "http://domain.com:8082/api/devices"
user = 'admin'
password = 'Password'

data = {

attributes:	{},
category:	default,
contact:	,
disabled:	true,
geofenceIds:	{},
groupId:	1,
id:	1,
lastUpdate:	2018-05-17T19:48:17+02:00,
model:	Huawei,
name:	Huawei,
phone:	+27833108523,
positionId:	21926,
status:	offline,
uniqueId:	671996}

headers = {"Content-Type": "application/json"}

response = requests.post(url, auth=(user, password), headers=headers, data=data)

print(response.text)

How can i disable/enable a device?

Thank You Anton

Anton Tananaev6 years ago

Check what official web app sends.