question

Tom-3176 avatar image
1 Vote"
Tom-3176 asked ·

IOT Central API

I am looking at using Azure IOT Central for condition monitoring of industrial machines.
My sensors will be connected to the cloud via a gateway devices that supports REST API
I would like to test the connectivity using an API simulation tool like POSTMAN, only it isn't very clear how to set up this connection.
I'm after something like this: https://stackoverflow.com/questions/58092672/azure-how-to-connect-to-iot-central-directly-via-api-or-webhook Only the poster doesn't clearly describe where he gets the 'HostName' from and how to set up the Authorisation header.
Are there any guides availabe for this?

azure-iot-central
· 5
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.

Hi Tom,


Thanks for reaching out to us!,


We have Azure IoT Central REST API documentation.


Please see :Azure IoT Central REST API reference, as well Azure IoT Central ARM SDK examples-for creating, updating, and removing IoT Central applications. Also please refer Manage IoT Central applications with the REST API to learn more about using the REST APIs via interactive learning journey. Please let us know if you need further help.


Please accept helpful responses as 'Answer', which will be helpful to other members as well.


0 Votes 0 · ·
Tom-3176 avatar image Tom-3176 SatishBoddu-MSFT ·

Hi Satish,
Thanks for your reply.
I have had a look at the API references you provided.
These references explain how to use REST API for creating, updating and removing applications, but that is not what I'm looking for.
I want to be able to connect a DEVICE to my application and send data to the application from that device using HTTP API.
I have had a look at the following section in your docs: https://docs.microsoft.com/en-us/azure/iot-central/core/tutorial-connect-device-python however this example abstracts away the raw API/MQTT code, which is fine if you have a device that supports python, however not helpful if your device supports only REST API or MQTT.
Tom

0 Votes 0 · ·

Hi Tom,

Could you please make use of the below URL to post few test telemetry from your POSTMAN, lets see if you can post some telemetry to my IOT Central APP.

Content-Type application/json


8495-post-iotc.gif


0 Votes 0 · ·
post-iotc.gif (383.8 KiB)
Tom-3176 avatar image Tom-3176 SatishBoddu-MSFT ·

I got it to work thanks!

1 Vote 1 · ·

Hi Tom,

Glad that your issue is unblocked now. Please mark the below response as 'Answer' which will help others as well. Please up-vote and leave a feedback on your experience with this Microsoft's Q&A community thread.

0 Votes 0 · ·

1 Answer

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

Hi Tom, If I understand correctly your Device to Application (Means IoT Central Application), if Yes, then below info will help.


Please see the Build the IoT Central device bridge to connect other IoT clouds to IoT Central.


"The function app is the critical piece of the device bridge. It receives HTTP POST requests from other IoT platforms or any custom platforms via a simple webhook integration. You can easily extend this solution to connect to your custom IoT cloud if your platform can send HTTP POST requests to your function app. "


External systems can feed device data through this device bridge and into your IoT Central app by making HTTP POST requests to the function URL.


Get the IoT Central device bridge from GitHub.


Let us know if this helps your scenario.


· 2 · 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.

Hi Satish,
Looking at that code, there is a lot of stuff in there to do with registering devices.
If the device is already registered manually in IOT Central, I can manually get ID Scope and SAS keys, do I still need to do that through the API?
For example when I try to call the API to get the device hub address, it requires ${response.operationId}, which it pulls from:

const registrationOptions = {
url: https://${registrationHost}/${context.idScope}/registrations/${deviceId}/register?api-version=${registrationApiVersion},
method: 'PUT',
json: true,
headers: { Authorization: sasToken },
body: { registrationId: deviceId }
};



However when I use the device sasToken from the Device Connection menu in IOT central, I get error unauthorized.

Is there not a way to push data direct to IOT Central without going through the registration process?

0 Votes 0 · ·

Hi Tom,

I have tried the IoT Central device bridge from GitHub, and was able to push telemetry data from Postman POST method. First I must create IoT Central APP and register a device to get scopeID , and device connection SAS key.
Then I have just deployed the template (Using ScopeID+SASkey) and grabbed the Function App URL and used directly in the Postman.
I mean, we should tell the bridge (function app) that where to send the data, so I believe that we need a target registered device on IoT Central.

Have you given it a try?

8533-iotc-bridges-monitor-app-postman.png


1 Vote 1 · ·