1

I am unable to read all the response form device-mgt api in between the response. I have the error stating "Connection #0 to host localhost left intact". Can you please help me to fix ?

Sample Response:

{"id":98,"dateOfEnrolment":1517461050248,"dateOfLastUpdate":1517461050248,"ownership":"BYOD","status":"ACTIVE","owner":"admin"}},{"id":99,"name":"003","type":"camera","description":"003","deviceIdentifier":"003","enrolmentInfo":{"id":99,"dateOfEnrolment":1517461108463,"dateOfLastUpdate":1517461108463,"ownership":"BYOD","status":"ACTIVE","owner":"admin"}},**{"id":100,"n* Connection #0 to host 192.168.1.18 left intact** ame":"004","type":"camera","description":"004","deviceIdentifier":"004","enrolmentInfo":{"id":100,"dateOfEnrolment":1517461156563,"dateOfLastUpdate":1517461156563,"ownership":"BYOD","status":"ACTIVE","owner":"admin"}},{"id":101,"name":"005","type":"camera","description":"005","deviceIdentifier":"005","enrolmentInfo":{"id":101,"dateOfEnrolment":1517461200437,"dateOfLastUpdate":1517461200437,"ownership":"BYOD","status":"ACTIVE","owner":"admin"}}]

Community
  • 1
  • 1
Vivek
  • 343
  • 1
  • 5
  • 12

1 Answers1

0

Seems your CURL command is incorrect.

Solution:

Please try below command;

curl -k -X GET 'https://192.168.1.18:8243/api/device-mgt/v1.0/devices?offset=0&limit=100' -H 'authorization: Bearer 41871ba0-3f12-3deb-a253-3911712a8187'

Explanation:

As per the CURL command; you are trying the port 8243. Port 8243 is HTTPS. Thus you need to specify the protocol as https://192.168.1.18:8243. You may also use port 8280 for HTTP communication.

Edit: You need to add https:// before the host name address of the API call. Please refer above API call carefully. And please refer this docs for offset and limit parameters. You can query devices in a paginated way with the offset and limit parameters.

Govinnage Rasika Perera
  • 2,134
  • 1
  • 21
  • 33
  • How to fix it in REST Client?. what is the meaning for **offset=0&limit=100** ? – Vivek Feb 01 '18 at 11:15
  • Please add 'https://' into front of the hostname of your REST client. `offset` and `limit` are well-known query parameters for the paginated REST APIs. Please refer https://docs.wso2.com/display/IoTS310/swagger/?url=https://docs.wso2.com/display/IoTS310/swagger/device-mgt.json#!/Device_Management/getDevices – Govinnage Rasika Perera Feb 01 '18 at 11:23
  • is it not possible to get all the device without using offset and limit? If i have more than 1000 device. How do i need to work with offset and limit. – Vivek Feb 01 '18 at 11:26
  • You cannot fetch all devices at once; this has implemented to avoid heavy load on the server. You can do the following; [1]. Fetch devices with the offset=0 and limit=1. [2]. Parse the response and get device count(device count here is all devices count). [3]. Fetch devices with the offset=0 and limit= – Govinnage Rasika Perera Feb 01 '18 at 11:39
  • Thank You So Much. If have device count more than 100. I have this issue. { "code": 400, "message": "Request parameter limit should be less than or equal to 100.", "errorItems": [] } – Vivek Feb 01 '18 at 11:46
  • Glad I could help you there. Your last query is not related to the original question, please go ahead and create a new question for your query. And if I answered to your question; please mark this as the answer. – Govinnage Rasika Perera Feb 01 '18 at 15:21