public string PostDevice([FromBody] dynamic data) { string id = Guid.NewGuid().ToString(); string name; if (data.name.ToString().Length == 0) { name = data.deviceType.ToString() + " - " + id; } else { name = data.name.ToString(); } var finalData = new { action = "registerDevice", source = "", callback = "", payload = new { deviceId = id, deviceName = name, deviceType = data.deviceType.ToString() } }; string jsonDataSet = JsonConvert.SerializeObject(finalData); string returnDataSet = JsonConvert.SerializeObject(finalData.payload); BrokerClient.sendMqttMessage(jsonDataSet, "Data-Controller"); return(returnDataSet); }