Add subscriptions via api
-
What is the correct syntax for adding a device using the API? I can delete a device using the API, but how to add is not specified (correctly) in the documentation.
-
I am a step further, sending the following:
curl -X POST https://[username:password]@iot.netwerk.t-mobile.nl/m2m/subscriptions/[subscription ID]/serialNumbers -H ‘Content-Type: application/json’ -d ’ { “serialNumbers”: [ “IMEI:451229637658708” ] }’gives:
{“subscriptionId”:“[subscription ID]”,“msg”:“Success”,“code”:1000}The IMEI is a valid random IMEI in this example. If I list all subscriptions, the IMEI is added. But if I go to my account and look at ‘Projects’, the IMEI is not shown…
Why?
-
Hmm thats odd, maybe because we’re migrating from iot.t-mobile.nl to iotcreators.com.
Can you please log out, delete cookies, clear cache, log-in and try again?
-
@afzal_m Hi Afzal, thnx for the response. I do not use the browser, I use curl, so no cookies, nor logins at all
-
But you said: 'if I go to my account and look at ‘Projects’…
-
Nevertheless, if it works find in the back-end I think the issue is related to this one:
https://forum.iotcreators.com/topic/583/no-device-data-in-gui -
@afzal_m Yeah you’re right :), however the ‘refresh table’ button works correctly, so it is not related to cookies
-
@afzal_m Maybe related indeed. I am going to do some tests and if that leads to interesting insights I will post them here
-
As promised the results of my test to try to register a brand new modem using API calls instead of using the portal. This was unsuccessful btw…
Using the API, I was successful in registering an IMEI of a brand new modem. If I used the API to return the registered IMEIs it was reported in the same way as the IMEIs that I did register through the portal. I was able to send messages but the messages where not forwarded to my cloud server.
Next I removed the IMEI from the subscriptions using the API and curl, and registered the IMEI in the portal. This was possible, however also now no data was forwarded to my cloud server. I think this is the already known issue that first you need to register and next to send the first message, and I already send messages in the first test as descibed above.My question is: could T-Mobille please provide working API calls for registering IMEIs?
This is in detail what I did. Username, password, subscription Ids, group name and IMEIs have been removed from the logs below for obvious reasons.
Check my registered IMEIs
curl -X GET ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/m2m/subscriptions?type=resources&groupName=<group name>’
Response
{“subscriptions”:[{“subscriptionId”:“<subscription 1>”,“resources”:[{“resourcePath”:“uplinkMsg/0/data”},{“resourcePath”:“downlinkMsg/0/data”}],“groupName”:“<group name>”,“criteria”:{“serialNumbers”:[“IMEI:xxx”,“IMEI:yyy”},“deletionPolicy”:0},{“subscriptionId”:“<subscription 2>”,“resources”:[{“resourcePath”:“uplinkMsg/0/data”},{“resourcePath”:“downlinkMsg/0/data”}],“groupName”:“<group name>”,“criteria”:{“serialNumbers”:[“IMEI:xxx”,“IMEI:yyy”},“deletionPolicy”:0}]}I am surprised that TWO subscriptions exists, with exactly the same list of IMEIs. Why?
Above call gave me two subscription Ids that I used in the following calls
Register a new IMEI in <subscription 1>
curl -X POST ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/m2m/subscriptions/<subscription 1>/serialNumbers’ -H ‘Content-Type: application/json’ -d ’ { “serialNumbers”: [ “IMEI:zzz” ] }’
Response:
{“subscriptionId”:“<subscription 1>”,“msg”:“Success”,“code”:1000}Register a new IMEI in <subscription 2>
curl -X POST ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/m2m/subscriptions/<subscription 2>/serialNumbers’ -H ‘Content-Type: application/json’ -d ’ { “serialNumbers”: [ “IMEI:zzz” ] }’
Response:
{“subscriptionId”:“<subscription 2>”,“msg”:“Success”,“code”:1000}Check if it is registered with the API (yes it is):
curl -X GET ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/m2m/subscriptions?type=resources&groupName=<group name>’
Response
{“subscriptions”:[{“subscriptionId”:“<subscription 1>”,“resources”:[{“resourcePath”:“uplinkMsg/0/data”},{“resourcePath”:“downlinkMsg/0/data”}],“groupName”:“<group name>”,“criteria”:{“serialNumbers”:[“IMEI:xxx”,“IMEI:yyy”,“IMEI:zzz”},“deletionPolicy”:0},{“subscriptionId”:“<subscription 2>”,“resources”:[{“resourcePath”:“uplinkMsg/0/data”},{“resourcePath”:“downlinkMsg/0/data”}],“groupName”:“<group name>”,“criteria”:{“serialNumbers”:[“IMEI:xxx”,“IMEI:yyy”,“IMEI:zzz”},“deletionPolicy”:0}]}If I check in the portal at https://portal.iot.t-mobile.nl/projects the IMEI is NOT shown
If I put in a brand new T-Mobile sim card I was able to register with T-Mobile, and to send messages, using the regular AT commands. The messages where accepted by the network. I think this is expected behavior, even without registration.
HOWEVER: the messages where not forwarded to my cloud server, leading to the conclusion: registering IMEIs using the API does not work.Next I removed the IMEIs from the subscriptions, for completeness I also give the commands for this:
Delete from subscription 1
curl -X DELETE ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/m2m/subscriptions/<subscription 1>/serialNumbers’ -H ‘Content-Type: application/json’ -d ’ { “serialNumbers”: [ “IMEI:zzz” ] }’
Response
{“subscriptionId”:“<subscription 1>”,“msg”:“Success”,“code”:1000}Delete from subscription 2
curl -X DELETE ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/m2m/subscriptions/<subscription 2>/serialNumbers’ -H ‘Content-Type: application/json’ -d ’ { “serialNumbers”: [ “IMEI:zzz” ] }’
Response
{“subscriptionId”:“<subscription 2>”,“msg”:“Success”,“code”:1000}Now I tried to register the same IMEI in the portal. This was successful but messages are again not forwarded to my cloud server. Also no IMSI, no first message, no last message nor payload is shown in the portal. This is probably because I sent messages in my test without a prior proper registration (this is a known issue)
-
I just talked to @Yassine-Amraue , he will get back to your question not later than tomorrow @JeroenD
-
@afzal_m Also thnx Afzal!
-
@afzal_m This one is also already solved. I took a look at the postman collection and distillated the curl command from it. This works! To those that are interested, it is possible to add a device using:
curl -X POST ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/impact/m2m/endpoints’ -H ‘Content-Type: application/json’ -d ’ {“additionalParams”: {“adaptationLayerName”:“TMNL_UDP_AL”},“address”: “”,“groupName”: “<group name>”,“identifier”: “”,“protocol”: “HTTP”,“serialNumber”: “IMEI:zzz”} ’
In this way the device is also shown in the portal
Maybe it is a good idea to update the (invalid) documentation!
-
The only thing I am still looking for is how to remove a device. According to the postman collection this should be:
curl -X GET ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/rest/device/14050’
But this shows device information and does not delete it.
-
I also found out how to remove a device. It is indeed the postman call but with a different method, not GET but DELETE. This is wrong in the postman collection also…
curl -X DELETE ‘https://<username>:<password>@iot.netwerk.t-mobile.nl/rest/device/14053’
-
Thanks a lot @JeroenD. Maybe you are not aware of it but last month with did a major update on the document library after two years. But we only focused on the devices part.
In August we will update the API part as well
@Roalnd-Baldin is already working on it. -
@afzal_m said in Add subscriptions via api:
Thanks a lot @JeroenD. Maybe you are not aware of it but last month with did a major update on the document library after two years. But we only focused on the devices part.
In August we will update the API part as well
@Roalnd-Baldin is already working on it.Nice @afzal_m