Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
I need to add a subscription to batch things,how to add subscription to thing via rest api?
Solved! Go to Solution.
Hi @YC_10946483
If you are asking about Dynamic Subscription
You can use the below endpoint
https://<<HOSTNAME>>/Thingworx/Things/<<THINGNAME>>/Services/AddDynamicSubcription
Method : POST
Content-Type : application/json
Body :
{
propertyName: logicProp,
eventName: "Alert",
thingName: undefined,
serviceName: "SubscriptionActionService"
}
Please refer this article for different input parameters - Article - CS388158 - Working with Dynamic Subscriptions in ThingWorx Platform (ptc.com)
/VR
Hi @YC_10946483
You can add Dynamic Subscription in RunTime or via API
Please refer to this article : Article - CS388158 - Working with Dynamic Subscriptions in ThingWorx Platform (ptc.com)
/VR
This method must create service before execute AddDynamicSubscription, i need add a subscription with my javaScript code and deal with some logic,is there any other method can resolve this?
You could add the service via API before and reference that in AddDynamicSubscription. https://community.ptc.com/t5/IoT-Tips/Create-a-service-dynamically/ta-p/820425
Or you can import a new Thing from XML and you generate the XML to have the code you want.
In any way, when you have code, you will change the Thing Model. Dynamic Subscriptions alone don't change the Thing Model.
can provide a example show how to add a subscription to thing via API?
Hi @YC_10946483
If you are asking about Dynamic Subscription
You can use the below endpoint
https://<<HOSTNAME>>/Thingworx/Things/<<THINGNAME>>/Services/AddDynamicSubcription
Method : POST
Content-Type : application/json
Body :
{
propertyName: logicProp,
eventName: "Alert",
thingName: undefined,
serviceName: "SubscriptionActionService"
}
Please refer this article for different input parameters - Article - CS388158 - Working with Dynamic Subscriptions in ThingWorx Platform (ptc.com)
/VR
i find that AddDynamicSubscription only work with local service but cannot call remote edge service , is it right?
Hi @YC_10946483
You can call another thing service. Please mention the edge thing name in the input parameter "thingName".
/VR
this thingName which i filled is a edge thing and this serviceName is in this thing
It should work. Dynamic Subscription won't be visible in composer.
You can use "IsDynamicSubscriptionCreated" to check whether the service is created or not
/VR