MQTT Publish to Thingstream using the Customer API

A number of web services are exposed via a swagger Customer API

This includes options to perform an MQTT Publish to Thingstream.


The Domain Key and Domain Secret will be required when making use of the Customer API.  These can be found in the Portal by logging into your domain, clicking on the domain name and selecting 'Domain Settings' from the drop down.  Clicking on 'Show Access Keys' will reveal the domain key/secret values.


Related content

MQTT Now 

IoT Communication-as-a-Service plans

Connecting to Thingstream using MQTT Spy 


Still need help?

If you need more help or have any questions, please send an email to services-support@u-blox.com.

Publishing to a Topic  

The Customer API offers the option to publish a 'string' to an MQTT Topic in addition to a binary payload to an MQTT Topic.

Clients and Thingstream Data Flows subscribe to MQTT Topics in order to receive messages published to those Topics.

The 'name' given to a Topic is also referred to within the Thingstream Portal, as a Subscription Path.  A Topic name may be multiple levels deep with each demarked level being denoted with a '/' to form a 'Path'.   (e.g. sensors/soil/out).

The basic payload for publish/topic/string takes the form:

{

  "deviceId": "string",

  "qos": 0,

  "topic": "string",

  "content": "string"

}

The basic payload for publish/topic/binary takes the form:

{

  "deviceId": "string",

  "qos": 0,

  "topic": "string",

  "base64binary": "string"

}

There is an optional "retained" value which can be added in the event that you wish all devices to receive a specific 'retained' message on subscription to the specified Topic.

The body of the publish takes the following values:

deviceId - The 'DeviceID' can be found on the Thing Details tab of an IP Thing in the Thingstream Portal.  This is the id of the Thing from which the message will originate.

qos - the expected guarantee of delivery for this message

4 QoS Levels are available:

• QoS -1 (Fire and forget from outside a session)

• QoS 0 (At most once)

• QoS 1 (At least once)

• QoS 2 (Exactly once)

topic - the topic on which the message will be published

content - the message that will be published to the specified topic

retained - when this flag is set to true, the server will 'retain' the message for delivery at the specified QoS to future subscribers whose topic matches the specified topic.

The Swagger interface will list a set of responses when you 'Try it out' they include:

Curl - This is the 'curl' representation of the publish just made.

Request URL - simply the API URL that made the call.

Request Headers - Any additional request headers will be displayed here.

Response Body - This includes a message Id as proof of publish.

Response Code - The ideal out come will prduce a 200 response any invalid outcome will have it's own code and is explained on each endpoint.

Response Headers - This will include things like Date, Type and Length.