Skip to content

Commit 3b1739a

Browse files
authored
Merge pull request #107422 from sunasing/patch-19
Added a sample code for creating metadata
2 parents 52f0fc0 + 47ab1d1 commit 3b1739a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

articles/industry/agriculture/ingest-historical-telemetry-data-in-azure-farmbeats.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,22 @@ curl -X POST "https://<datahub>.azurewebsites.net/Device" -H
279279
\"description\": \"Test Device 123\"}" *
280280
```
281281

282+
Below is a sample code in Python. Please note that the access token used in this sample is the same that we received during authentication
283+
284+
```python
285+
import requests
286+
import json
287+
288+
# Got access token - Calling the Device Model API
289+
headers = {
290+
"Authorization": "Bearer " + access_token,
291+
"Content-Type" : "application/json"
292+
}
293+
payload = '{"type" : "Node", "productCode" : "TestCode", "ports": [{"name": "port1","type": "Analog"}], "name" : "DummyDevice"}'
294+
response = requests.post(ENDPOINT + "/DeviceModel", data=payload, headers=headers)
295+
```
296+
297+
282298
> [!NOTE]
283299
> The APIs return unique IDs for each instance created. You must retain the IDs to send the corresponding telemetry messages.
284300

0 commit comments

Comments
 (0)