# Looking for help sending queries to LwM2M devices via the Open API

**URL:** <https://community.cumulocity.com/t/looking-for-help-sending-queries-to-lwm2m-devices-via-the-open-api/3965>\
**Category:** Forum\
**Tags:** cumulocity\
**Created:** [February 23, 2022, 6:18pm UTC](https://community.cumulocity.com/t/looking-for-help-sending-queries-to-lwm2m-devices-via-the-open-api/3965 "2022-02-23T18:18:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim.veneskey](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jim.veneskey](https://community.cumulocity.com/u/jim.veneskey)\
**Post date:** [February 23, 2022, 6:18pm UTC](https://community.cumulocity.com/t/looking-for-help-sending-queries-to-lwm2m-devices-via-the-open-api/3965/1 "2022-02-23T18:18:39Z")

</div>

#### What product/components do you use and which version/fix level?

Cumulocity IOT specifically LWM2M  
Version: 1011.0.12

#### Are you using a free trial or a product with a customer license?

Product with a customer license

#### What are trying to achieve? Please describe in detail.

I am attempting send queries and receive responses from my LwM2M devices registered with cumulocity by using the public API.  
Specifically, I would like to perform operations such as “READ 1/0/1” “WRITE 3/0/3” etc  
These operations are available from the “Shell” sidebar link when selecting an LwM2M device in my account, but I need to be able to do this in an automated fashion for my testing.

I am aware of the interactive  
cumulocity API browser  
(Forum will not allow me to link to a cumulocity page?!)  
But I see nothing there that supports sending requests I am currently using the shell (manually) for.

#### Do you get any error messages? Please provide a **full error** message screenshot and log file.

N/A since I haven’t been able to find the correct API yet

---

<div class="post-metadata">

**Author:** ![Christian\_Guether1](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/christian_guether1/32/14848_2.png) [@Christian\_Guether1](https://community.cumulocity.com/u/Christian_Guether1)\
**Post date:** [February 24, 2022, 7:36am UTC](https://community.cumulocity.com/t/looking-for-help-sending-queries-to-lwm2m-devices-via-the-open-api/3965/2 "2022-02-24T07:36:56Z")

</div>

Hi Jim,

if I understood you correctly you want to send [Shell commands](https://cumulocity.com/guides/users-guide/device-management/#shell) automatically using the API. Shell commands itself are just [Cumulocity Operations](https://cumulocity.com/api/10.10.0/#operation/postOperationCollectionResource) using a specific structure. An example for Shell command looks like this:

```json
{
  "deviceId": "3100", // the device id for which you want to send the shell command
  "description": "Execute shell command", // description
  "c8y_Command": { // the c8y_Command fragment to identify this operation as a shell command
    "text": "12" // the actual command you want to send to your device
  }
}

```

Depending on the messages you want to send, you can simply replace the content of the text property within the operation.

As a general tip, you can use the Developer Tools of your browser to perform some basic reverse engineering how the Cumulocity UI communicates with the REST API. Simply open the Network tab of Developer tools and monitor the requests being sent by the platform. If you trigger for example a shell command from the UI, you will see that a new operation with the specified command has been created:

 ![developer_tools](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/8/9/890da1a6cf6ce34c47eb2ae4eb7f40e4bcf81ae5.png)

Best regards  
Christian

---

<div class="post-metadata">

**Author:** ![jim.veneskey](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jim.veneskey](https://community.cumulocity.com/u/jim.veneskey)\
**Post date:** [March 1, 2022, 2:29pm UTC](https://community.cumulocity.com/t/looking-for-help-sending-queries-to-lwm2m-devices-via-the-open-api/3965/3 "2022-03-01T14:29:29Z")

</div>

Hi,  
I took your advice and used the chrome developer console to view the transactions my browser was submitting from the web console.

Turns out - there is a really handy feature I never knew about - where you can copy the network transaction as curl - and then I simply pasted it into a curl-2-python conversion page which allowed me to easily add it to my python automation tests.

I really wish I could have figured out their documentation - but doing it this way is actually much easier.

thanks for the suggestion!

Jim

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [May 30, 2022, 2:29pm UTC](https://community.cumulocity.com/t/looking-for-help-sending-queries-to-lwm2m-devices-via-the-open-api/3965/4 "2022-05-30T14:29:41Z")

</div>

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