POST /geofences API ignores Geofence object id property

Ivan Mudryj5 years ago

When creating geofences thru the POST API, a Geofence object is sent by Body Parameter, but it is created using an auto-increment id instead of using the id property of object passed as parameter.
I need to know what ID my new geofence will get in order to be able to make future modifications (PUT API). I think, I should get the complete list of geofences before creating a new one, and assume I'll get the next ID available. Is that correct??

It would be cool if the Geofence object on the response could have the actual ID that the geofence finally get after the POST API call, but I am getting the same value I've sent.

Anton Tananaev5 years ago

It should return correct id.

Ivan Mudryj5 years ago

My fault, I double checked and I could see that I'm gettin the correct ID within the response as you said, thanks for your help!

One thing I could check is that when I request a geofence PUT API, no matter if I send an existing ID the API says: 200 OK. But I think it would be better if it were some ID validation to response "Invalid id" or something if I'm trying to modify/update a not existing geofence.

Another question: Is there any way to create a geofence that automatically applies to all the devices? Or should I have to call the API to modify them all? If I have more than 500 devices and I create a geofence, I will be calling the device update 500 times. Can you please help me on this subject? Thanks a lot Anton!

Anton Tananaev5 years ago

PUT uses id from the URL path and it should fail if it doesn't exist, as far as I know.

As for linking to devices, you can have all your devices in a group and link geofence to that group.

Ivan Mudryj5 years ago

About the geofences PUT, please check it, I'm pretty sure that's is not happening.
Description text
Description text

About linking to devices: That's sounds Great! I'll try.
Thanks a lot!

Anton Tananaev5 years ago

I guess update SQL request succeeds even if no records found.

Ivan Mudryj5 years ago

That sounds logical, and makes me bolster that there may not be a prior validation of the existence of the ID or later verification of records affected by the update. Only one comment that could be improvement in future versions, I think it is an excellent software.