Hi all i using cumulocity api with php , is all ready. I have problem with get event/events by deviceId.
$url = 'https://*********.iot.a1.digital/event/events?dateFrom=' . $date . 'T' . $timeNew . '.000Z&pageSize=1000&type=lwm2m_log';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Acept: application/vnd.com.nsn.cumulocity.operation+json',
));
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);
My url is
https://********_live.iot.a1.digital/event/events?dateFrom=2020-08-28T14:02:07.000Z&pageSize=1000&type=lwm2m_log&id=1234567
but return data is all event for all device.
answer
"events": [
{
"creationTime": "2020-12-07T09:49:13.879+01:00",
"source": {
"name": "860922049984564",
"self": "https://t14580169.iot.a1.digital/inventory/managedObjects/1973856",
"id": "1973856"
},
"type": "lwm2m_log",
"self": "https://t14580169.iot.a1.digital/event/events/13113138",
"time": "2020-12-07T09:49:13.874+01:00",
"text": "Registration update: RegistrationUpdate [registrationId=ivWv8hUHh2, identity=Identity /80.75.32.47:24140[unsecure], lifeTimeInSec=null, smsNumber=null, bindingMode=null, objectLinks=[</31101/0>, </5/0>, </3/0>, </6/0>]]\nUpdated registration: Registration [registrationDate=Mon Nov 23 09:19:00 CET 2020, identity=Identity /80.75.32.47:24140[unsecure], lifeTimeInSec=360, smsNumber=null, lwM2mVersion=1.0, bindingMode=U, endpoint=860922049984564, registrationId=ivWv8hUHh2, objectLinks=[</31101/0>, </5/0>, </3/0>, </6/0>], lastUpdate=Mon Dec 07 09:49:13 CET 2020]",
"id": "13113138"
}
]
How to create url get by deviceId
To query events (or other data types) by source device ID, please use the query parameter "source" instead. See https://cumulocity.com/guides/reference/events/#events-api
Your query should look like this: