Jump toUpdate content
How to set up and use a REST network
IoT Hub allows you to configure and use REST networks for your IoT applications.
The REST network only allows publishing messages.
- Click IoT Hub in the Managed Services section of the side menu. The list of your IoT Hubs displays.
- Click the name of the IoT Hub that you want to configure. The hub’s overview page displays.
- Click the Networks tab on the hub’s overview page.
- Click the Add network button to access the network creation wizard.
- Complete the form by specifying the network’s details:
- Enter a name for your network.
- Choose REST as the type of network you want to create.
- Choose a topic prefix your network should publish to. You may leave this empty. All the messages published to this network will have their topics prefixed with this value.
- Click Create Network. A summary of the network you created, displays. Take note of the two key parameters:
- The network endpoint.
- The network secret. Be careful, this secret will only be shown once !
Keep this information, you need it to use your REST network.
Any HTTP client can be used to publish a message through a REST network. The required headers are:
X-Secret: The network secret that was given while creating the network on a Hub.
X-Topic: The topic that the message should be published on.
Following an example using curl:
> curl -XPOST -H "X-Secret: <network-secret>" -H "X-Topic: <topic>" -d <payload> <network-endpoint>
Use the following values:
<network-secret>: Enter here the network secret that was given when you created the network on your Hub.
<network-endpoint>: Enter here the network endpoint that was given when you created the network on your Hub.
<topic>: Choose here the topic that suits your needs. This topic will be prefixed with the network topic.
<payload>: Enter here the payload you want to publish (a JSON string as example).