API access does not work
-
I am trying to access my device with the API. I have tried many different commands with curl PUT and GET and different URL options advised in other posts and but it keeps failing with:{ “msg”: “Unauthorized”,“code”:1001}
Let use the following command : curl -X GET ‘https://iot.netwerk.t-mobile.nl/m2m/subscriptions?type=resources&groupName=CON_000000XXXX’ -H ‘Authorization: Basic XXXXX0NPTl8wMDAwMDAxNDY1X2EzMThiOkUyM2dVKzM0S0AmYVJlXXX’
The groupName is correct (changed for this posting)
The authorization string (base64 username: password) is correct. I have double-checked that by entering this on another side on the internet to decode and that resulted in the correct username: password (changed for this posting).Somewhere I saw that you need to create the device first through the API instead of using the web-pages. Is that why it would not work or what am I doing wrong?
regards,
Paul -
@paulvha This URL and headers work for me:
To get the list of all devices:
URL:
GET https://iot.netwerk.t-mobile.nl:443/rest/device?iDisplayLength=-1Headers:
Content-Type:application/json
Authorization:Basic base64(<USERNAME>:<PASSWORD>)
Accept:application/jsonThis should work with your credentials:
curl -X GET https://iot.netwerk.t-mobile.nl:443/rest/device?iDisplayLength=-1 -H 'Authorization:Basic base(<USERNAME>:<PASSWORD>)As you can see the request works also without Content-Type and Accept.
To get the details of a single device:
URL:
GET https://iot.netwerk.t-mobile.nl:443/rest/device/<ID>Headers:
Content-Type:application/json
Authorization:Basic base64(USERNAME:PASSWORD)
Accept:application/jsonTo get the details of the device don’t use the deviceId!
Regards, Roland
-
Thansk Roalnd. Sorry for the delay… had another project. This works for me as well and now I can continue.
regards,
Paul