telefonicaid / fiware-IoTAgent-Cplusplus

IoTAgent development framework for C++
GNU Affero General Public License v3.0
11 stars 57 forks source link

Error updating device content #410

Open usuarioIOT opened 8 years ago

usuarioIOT commented 8 years ago

We are having troubles updating values on a created device. We have followed your examples scripts and we have create a device on IoTAgent by posting:

curl -X POST http://127.0.0.1:8080/iot/devices \ -i \ -H "Content-Type: application/json" \ -H "Fiware-Service: testservice" \ -H "Fiware-ServicePath: /testsubservice" \ -d ' { "devices": [ { "device_id": "device_id", "entity_name": "entity_name", "entity_type": "entity_type", "protocol" : "PDI-IoTA-UltraLight", "timezone": "America/Santiago", "attributes": [ { "object_id": "source_data", "name": "attr_name", "type": "int", "metadatas":[ {"name": "metaname", "type": "int", "value": "45"} ] } ], "static_attributes": [ { "name": "att_name", "type": "string", "value": "value", "metadatas":[ {"name": "metaname", "type": "string", "value": "45"} ] } ] } ] }'

That works fine. But when we want to update a field of device, by using PUT, i.e. "timezone" with the example script:

curl -X PUT http://127.0.0.1:8080/iot/devices/device_id \ -i \ -H "Content-Type: application/json" \ -H "Fiware-Service: testservice" \ -H "Fiware-ServicePath: /testsubservice" \ -d '{ "timezone": "Europe/Madrid" }'

We get the following error:

HTTP/1.1 400 Bad Request Connection: close {"reason":"A parameter is missing in the request","details":"protocol parameter is mandatory"}

We will appreciate if you can clarify how can we update device info with PUT,

Thank in advance,

agonlucas commented 8 years ago

Hello, As details field says, field “protocol” is mandatory. Why? A device (device_id) may be in different services using different protocols. You are using protocol in POST. Timezone is a field with no specific use (as documentation says).

Agus.

De: usuarioIOT notifications@github.com<mailto:notifications@github.com> Responder a: telefonicaid/fiware-IoTAgent-Cplusplus reply@reply.github.com<mailto:reply@reply.github.com> Fecha: jueves, 3 de marzo de 2016, 16:56 Para: telefonicaid/fiware-IoTAgent-Cplusplus fiware-IoTAgent-Cplusplus@noreply.github.com<mailto:fiware-IoTAgent-Cplusplus@noreply.github.com> Asunto: [fiware-IoTAgent-Cplusplus] Error updating device content (#410)

We are having troubles updating values on a created device. We have followed your examples scripts and we have create a device on IoTAgent by posting:

curl -X POST http://127.0.0.1:8080/iot/devices \ -i \ -H "Content-Type: application/json" \ -H "Fiware-Service: testservice" \ -H "Fiware-ServicePath: /testsubservice" \ -d ' { "devices": [ { "device_id": "device_id", "entity_name": "entity_name", "entity_type": "entity_type", "protocol" : "PDI-IoTA-UltraLight", "timezone": "America/Santiago", "attributes": [ { "object_id": "source_data", "name": "attr_name", "type": "int", "metadatas":[ {"name": "metaname", "type": "int", "value": "45"} ] } ], "static_attributes": [ { "name": "att_name", "type": "string", "value": "value", "metadatas":[ {"name": "metaname", "type": "string", "value": "45"} ] } ] } ] }'

That works fine. But when we want to update a field of device, by using PUT, i.e. "timezone" with the example script:

curl -X PUT http://127.0.0.1:8080/iot/devices/device_id \ -i \ -H "Content-Type: application/json" \ -H "Fiware-Service: testservice" \ -H "Fiware-ServicePath: /testsubservice" \ -d '{ "timezone": "Europe/Madrid" }'

We get the following error:

HTTP/1.1 400 Bad Request Connection: close {"reason":"A parameter is missing in the request","details":"protocol parameter is mandatory"}

We will appreciate if you can clarify how can we update device info with PUT,

Thank in advance,

— Reply to this email directly or view it on GitHubhttps://github.com/telefonicaid/fiware-IoTAgent-Cplusplus/issues/410.


Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.

The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.

Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição

usuarioIOT commented 8 years ago

Hi, Thanks. We are trying to specify protocol in the data of the PUT request ("protocol" : "PDI-IoTA-UltraLight") but it still doesn't work. We would like to change for example metaname value from 45 to 50 and add a command to a device. Can you clarify with an example how can we perform that?

We have created the device with this POST:

curl -X POST http://127.0.0.1:8080/iot/devices \ -i \ -H "Content-Type: application/json" \ -H "Fiware-Service: testservice" \ -H "Fiware-ServicePath: /testsubservice" \ -d ' { "devices": [ { "device_id": "device_id", "entity_name": "entity_name", "entity_type": "entity_type", "protocol" : "PDI-IoTA-UltraLight", "timezone": "America/Santiago", "attributes": [ { "object_id": "source_data", "name": "attr_name", "type": "int", "metadatas":[ {"name": "metaname", "type": "int", "value": "45"} ] } ], "static_attributes": [ { "name": "att_name", "type": "string", "value": "value", "metadatas":[ {"name": "metaname", "type": "string", "value": "45"} ] } ] } ] }'

Thanks in advance,

usuarioIOT commented 8 years ago

Hi,

Finally done! We have tried with protocol identifier instead of protocol name and it works.