HomeManaged ServicesIoT HubHow to
Set up and use a REST network
Jump toUpdate content
How to set up and use a REST network
Published on 01 September 2019
IoT Hub allows you to configure and use REST networks for your IoT applications.
Security & Identity (IAM):
You may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
- You have an account and are logged into the Scaleway console
- You have created an IoT Hub
The REST network only allows publishing messages.
How to set up a REST network
- 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.
How to use the 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).