How we can execute shell command from custom widget using code

Product/components used and version/fix level are you on:

Backend: 1015.0.278
UI: 1011.0.38

Detailed explanation of the problem:

I have custom widget in angular on top of Application Builder


Widget Look like above image and below is the widget code in my IDE

now i want to Execute shell command from this widget code to cumulocity shell till now i have not done any Cumulocity connection and all so how i can execute shell command from custom widget code and what steps I have to do for Executing shell command from custom widget code then from widget code I will call a Alarm Rest Api from widget code once shell command executed from custom widget code then we will use values of rest API in custom widget.

how can I achieve this any docs or info will be helpful.

I want :-

  1. Execute Shell command from custom widget code
  2. once done with shell command execution in custom widget code I want to call my alarm rest API and use these values in custom widget

is there any approach for achieve this ?

Error messages / full error message screenshot / log fileL

Is your question related to the free trial, or to a production (customer) instance?

Have you installed all the latest fixes for the products and systems you are using?

Hi Sumit,

All Communication from UI(angular) app to backend is via REST APIs.
I am not sure what are you referring here as “Shell Command”.
Can you please share more details.

Thank You @Darpankumar_Lalani for your valuable response
From my main application I am able to call my REST API over MQTT
my device is connected to Cumulocity and my main UI


refer the above image here my Cumulocity cloud is connected to Cumulocity now when i am sending from device shell this payload from shell

refer the above image here i am executing this payload from connected device and I am able to call my REST API in same manner I want to call my REST API in widget code

here i want to call my REST API how can I achieve this ?
doing all the because the REST API needed AUTH token that’s why I am doing all this so please help me with this scenario how can I call my REST API from this widget code

all these I am doing over MQTT.

a little help can resolve my problem my end goal is to call REST API how can I achieve this in my custom widget code if I don’t have auth token, what kind of things I need to do REST API call from my custom run time widget code .

I am stuck to call rest API from my widget code , I am connected to my device and cumulocity thought my product application there i am easily able to call my rest API over mqtt here how can i call rest API over mqtt

is there any way or approach to achieve this ?

If I understood correctly, you are looking for Operation API.
Please check below URL about how to call Operation Rest APIs from UI. OperationService | Cumulocity Web SDK

For More details about operations, you can refer Device Management - Cumulocity IoT Guides

Thank You @Darpankumar_Lalani
But You didn’t understand it i just want to call my rest API over mqtt
how i can call my rest API over mqtt in my custom widget code ?

some example or info will be enough, if you share with me related to call rest API over MQTT in my custom widget code .

When you execute Shell command from device management (in your screenshot), it will call Operation API from cumulocity.
You can verify that in browser developer tool by right-click in browser-> inspect → network tab.
In network tab you will find operation API rest call with your json payload.

As per my understanding, you want to call same API from your widget. In that case you need to use Operation REST APIs.

Thank You @Darpankumar_Lalani can you provide some code references or example to integrate this Operation API in my Angular based custom widget ?

You can refer Device Control Widget.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.