So far is it possible to manage IoT devices with Velocity? For example, send a command to device like this:
POST https://{Endpoint}/v5/iot/{project_id}/devices/{device_id}/commands
Content-Type: application/json
X-Auth-Token: ********
{
"service_id" : "WaterMeter",
"command_name" : "ON_OFF",
"paras" : {
"value" : "ON"
}
}
Solved! Go to Solution.
Hi Arthur,
What you're asking is definitely possible with ArcGIS Velocity. To achieve this task, you would want to use the HTTP output to construct a POST request. Simply provide the URL, select the content type (JSON), and add any additional headers (e.g authorization token). For the message body, you'd wrap your JSON object using the Text() Arcade expression so that you can keep the JSON formatted. You can even parameterize the values in your JSON by referencing the fields from your processed data.
As an example, here is what I had tested using your sample data. The bold parts indicate what I mentioned about about Arcade/parametrized data:
text({
"service_id" : $feature["service_id"],
"command_name" : $feature["command_name"],
"paras" : {
"value" : $feature["paras_value"]
}
})
Hi Arthur,
Instead of using URL parameters, you'll want to click on "configure expression" to format your JSON object using Arcade. The only thing, based on your example, that you'll want to have as a URL parameter is the authorization token.
Click here to configure your JSON body using Arcade:
Specify the following to maintain the JSON object with dynamic field values. Note the resulting JSON when I tested the expression:
Lastly, it's important to note that the field "paras_value" exists because I flattened the paras object as part of the feed schema. If you didn't flatten "paras" as part of the feed schema, then its likely your field name and value will be different.
Hi Arthur,
What you're asking is definitely possible with ArcGIS Velocity. To achieve this task, you would want to use the HTTP output to construct a POST request. Simply provide the URL, select the content type (JSON), and add any additional headers (e.g authorization token). For the message body, you'd wrap your JSON object using the Text() Arcade expression so that you can keep the JSON formatted. You can even parameterize the values in your JSON by referencing the fields from your processed data.
As an example, here is what I had tested using your sample data. The bold parts indicate what I mentioned about about Arcade/parametrized data:
text({
"service_id" : $feature["service_id"],
"command_name" : $feature["command_name"],
"paras" : {
"value" : $feature["paras_value"]
}
})
Hi Gregory,
We tried but failed when reference to the fields from processed data, actually it changed the $feature["field_name"] to string "$feature[\"field_name\"] ". So any further suggestion?
Hi Arthur,
Instead of using URL parameters, you'll want to click on "configure expression" to format your JSON object using Arcade. The only thing, based on your example, that you'll want to have as a URL parameter is the authorization token.
Click here to configure your JSON body using Arcade:
Specify the following to maintain the JSON object with dynamic field values. Note the resulting JSON when I tested the expression:
Lastly, it's important to note that the field "paras_value" exists because I flattened the paras object as part of the feed schema. If you didn't flatten "paras" as part of the feed schema, then its likely your field name and value will be different.
Great, thank you @GregoryChristakos very much, I will try.