Farmbeats: Failed to Create Device using Swagger API (Post) /Device

Hisashi Goto 116 Reputation points Microsoft Employee
2020-06-15T05:00:42.153+00:00

When I tried to crate a dvice from Swagger API .. from URL.."https://xxxfarmbeats-api.azurewebsites.net/swagger/"

I copied and paste deviceModelID from "GET /Device"...

When I tried to create a device, "POST /Device"
It returns error code 400 with error message... device model does not exist...

{
  "message": "Device model with id 02c7801c-e91d-46dd-898e-35a4716a223a doesn't exists",
  "status": 400,
  "code": "DeviceModelIdNotFound",
  "moreInfo": null
}

How to set Device Model ID?

--reference -Body message used for "POST /Device" ---

{
  "deviceModelId": "02c7801c-e91d-46dd-898e-35a4716a223a",
  "hardwareId": "dummydevice001",
  "farmId": "1c43b019-42f1-420e-8db9-a3f9e7b69925",
  "reportingInterval": 300,
  "location": {
    "latitude": 38.50723,
    "longitude": -120.7948768,
    "elevation": 0
  },
  "name": "YoumustDeleteIt",
  "description": "Temporary device for Testing API please delete it"
}

Best Regards

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,970 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hisashi Goto 116 Reputation points Microsoft Employee
    2020-06-23T06:07:48.653+00:00

    Thank you for your support...

    I tried to create a new device model as you suggested, "Please follow the steps here to enable partner access"...

    or ...

    [POSt]  /DeviceModel
    (message body)
    {
      "type": "Node",
      "manufacturer": "HGdummyCompany",
      "productCode": "1234567900",
      "ports": [
        {
          "name": "Port0",
          "type": "Analog"
        }
      ],
      "name": "HGDUMMYDEVMODEL01",
      "description": "dummy device model"
    
    }
    

    Then, I could get a new Model ID in response body { id: 23353149-9e3f-401b-b97b-0aa6bc0c4dca}
    By using the id, I tried to create a device...

    [POST] /Device
    {message body}
    {
      "type": "Node",
      "manufacturer": "HGdummyCompany",
      "productCode": "1234567900",
      "ports": [
        {
          "name": "Port0",
          "type": "Analog"
        }
      ],
      "name": "HGDUMMYDEVMODEL01",
      "description": "dummy device model"
    }
    

    The results are OK, I could succeeded to create a new devcie, then confirmed my device is listed in FarmBeats Dashboard..

    Best Regards
    Hisashi Goto


1 additional answer

Sort by: Most helpful
  1. Sunayana Singh 91 Reputation points Microsoft Employee
    2020-06-15T11:42:26.807+00:00

    Hi, The DeviceModelId needs to be created by a client application which has a partner role assigned to it. Please follow the steps here to enable partner access. You can then use the credentials as mentioned in the document to create the DeviceModel, Device etc.