How to assing geofence to device?

Nelson Miranda4 years ago

I would like to know if it's possible to assign a geofence to a existing device using the api?
If it is, then what is the correct way to do so?
I tried doing a PUT request but it doesn't reaspond correctly.
I tried this but it doesn't work:

Geofences ids: 25,26,27
Request to assign geofences id 25 to device with 31 id

HTTParty.put(url + 'api/devices/' + 31,
  :body => {
    "id": 31,
    "groupId": 16,
    "name": "Device Test",
    "uniqueId: "xxxxxxxx",
    "geofencesIds": [25],
    "disabled": false
  },
  :headers => { "Content-Type" => "application/json" },
  :basic_auth => { :username => "username", :password => "password" })
Anton Tananaev4 years ago

I would recommend checking what the official web app does.

Nelson Miranda3 years ago

I can do it from the official web app and it works correctly, but
is it possible to link a geofence to a device through the api?

Anton Tananaev3 years ago

Official web app uses the same API.