Updating topics
You can set and update the value of a topic with the REST API.
Endpoint |
|
Content-type |
|
Method |
|
curl --include \
--request POST \
--url https://api.diffusion.cloud/topics/set \
--header 'authorization: Bearer <TOKEN>' \
--header 'content-type: application/json' \
-d '{"path":"my-topic", "type":"json", "value": {"foo": "bar"}}'
Parameter | Optional? | Default | Description |
---|---|---|---|
path |
No |
— |
The Diffusion topic path as a string. |
value |
No |
— |
The value to set the topic to. |
type |
Yes |
json |
The type of topic. This can be either json or string. |
Code | Description |
---|---|
|
The topic was updated successfully (or already has the value supplied). |
|
There was a problem updating the topic due to the parameters supplied. See |
|
There was an unexpected problem updating the topic. See |
Updating a topic that may not exist
You can set the value of a topic, even if it doesn’t exist with the REST API. If no topic exists, one will be created and set to the value specified. If a compatible topic already exists, the topic will be updated to the new value.
In order to update an already existing topic, the topic type and properties in the request must be compatible with the existing topic. |
Endpoint |
|
Content-type |
|
Method |
|
curl --include \
--request POST \
--url https://api.diffusion.cloud/topics/addAndSet \
--header 'authorization: Bearer <TOKEN>' \
--header 'content-type: application/json' \
-d '{"path":"my-topic",
"type":"json",
"properties":{ "VALIDATE_VALUES":"true" },
"value":{"foo": "bar"},
}'
Parameter | Optional? | Description |
---|---|---|
|
No |
The path at which the topic must be added. |
|
No |
The value to set the topic to. |
|
Yes |
The topic type. The default value is |
|
Yes |
A map of topic properties. The default value is |
Code | Description |
---|---|
|
The topic was added (or a topic already exists), and its value was set successfully. |
|
There was a problem adding the topic due to the parameters supplied. See |
|
There was an unexpected problem adding the topic. See |