I have added a dynamic subscription by rest api and i check it out by call
Solved! Go to Solution.
Hi @YC_10946483,
The Dynamic Subscriptions are created in-memory and are not persisted like a normal subscription (otherwise you would see them anyway in the Subscription page).
You just need to add AddDynamic.... call in the ThingStart event to make sure it's added to the Thing when it restarts.
This information is also present in the help center as a note in this page: https://support.ptc.com/help/thingworx/platform/r9.5/en/#page/ThingWorx/Help/Composer/Things/ThingSubscriptions/ProgrammaticallyEnablingDisablingSubscriptions.html
Hi @YC_10946483,
The Dynamic Subscriptions are created in-memory and are not persisted like a normal subscription (otherwise you would see them anyway in the Subscription page).
You just need to add AddDynamic.... call in the ThingStart event to make sure it's added to the Thing when it restarts.
This information is also present in the help center as a note in this page: https://support.ptc.com/help/thingworx/platform/r9.5/en/#page/ThingWorx/Help/Composer/Things/ThingSubscriptions/ProgrammaticallyEnablingDisablingSubscriptions.html
Ok,thanks! Is there any rest api i can add a persisted subscription just like i added in thingworx thing page ?
A direct API not, because generally speaking everything involving Javascript code (creating a service or a subscription) is done through Composer. However, it's entirely possible due to ThingWorx's fully REST-based architecture.
You need to 1. download the XML (GET) 2. Add the subscription in the XML you got the 3. Write back the entity (PUT, which is exactly what Composer does when saving it).
For step 2, if you want to know where to add that subscription you can compare the XML from an entity before and after you add a normal subscription (I use VS Code and its Compare functionality usually here.). And obviously Step 2 needs some sort of logic to manipulate the XML (locate the node then add the subscription to that node)