question

sunayana avatar image
1 Vote"
sunayana asked ·

Create device or sensor metadata

I am following this tutorial https://docs.microsoft.com/en-us/azure/industry/agriculture/ingest-historical-telemetry-data-in-azure-farmbeats to creates a device but it is returning an error. Here is the code I submitted


PS Azure:\> curl -X POST "https://tet-dh1.azurewebsites.net/Device" -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer <My access-token>" -d "{ \"deviceModelId\": \"ID123\", \"hardwareId\": \"MHDN123\", \"reportingInterval\": 900, \"name\": \"Device123\", \"description\": \"Test Device 123\"}"*


Here is the error it returns


 {"message":"Model validation failed","status":400,"code":"ModelValidationFailed","moreInfo":"[\"Invalid property identifier character: \\\\. Path '', line 1, position 3.\"]"}curl: (6) Could not resolve host: deviceModelId\: \ID123\,  \hardwareId\: \MHDN123\,  \reportingInterval\: 900,  \name\: \Device123\, \description\ 
 curl: (6) Could not resolve host: Device 
 curl: (6) Could not resolve host: 123} 
 curl: (7) Failed to connect to * port 80: Connection refused 
azure-farmbeats
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AshokPeddakotla-MSFT avatar image
0 Votes"
AshokPeddakotla-MSFT answered ·

You will need to create a device Model first (using DeviceModel API) and then create the device using the id of the deviceModel created.

\"deviceModelId\": \"ID123\" - Once you create the deviceModel, you can specify the id of that in the input payload of Device.
Hope this helps.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.