cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Some question about AddDynamicSubscription

YC_10946483
5-Regular Member

Some question about AddDynamicSubscription

 I have added a dynamic subscription  by rest api and i check it out by call 

IsDynamicSubscriptionCreated ,it is yes ;but when i click save in the thingworx  thing page and then i recalled IsDynamicSubscriptionCreated  the answer is no ?
 

YC_10946483_1-1709277868506.png

 

YC_10946483_0-1709277831418.png

YC_10946483_2-1709278192332.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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

YC_10946483
5-Regular Member
(To:VladimirRosu)

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)

Top Tags