Waziup / WaziGate

Waziup LoRa Edge gateway
21 stars 20 forks source link

API: Internal error 500 when creating a device twice #160

Open cdupont opened 3 years ago

cdupont commented 3 years ago

If you try to create a device twice, it result in an error 500:

$ TOK=`curl -vvv -X POST "http://172.16.11.187/auth/token" -d "{\"username\":\"admin\",\"password\":\"loragateway\"}" | tr -d '"'`
$ curl -X POST "http://172.16.11.187/devices" -H  "accept: text/plain" -H  "Content-Type: application/json" -H "Authorization: Bearer $TOK" -d '{"id" : "test"}'
$ curl -X POST "http://172.16.11.187/devices" -H  "accept: text/plain" -H  "Content-Type: application/json" -H "Authorization: Bearer $TOK" -d '{"id" : "test"}'
HTTP/1.1 500 Internal Server Error
j-forster commented 3 years ago

It is not intended to allow passing Ids when creating any entity - it results in undefined behavior right now. Dealing with that problem will be covered by https://github.com/Waziup/WaziGate/issues/161.